【发布时间】:2016-05-17 22:42:16
【问题描述】:
这是我当前的布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#F5F5DC"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RadioButton android:id="@+id/radio_red"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/flag_dk"
android:textColor="#000000"
android:layout_gravity="center_horizontal"
android:drawablePadding="10dip"
android:text="Danish" />
<RadioButton android:id="@+id/radio_blue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/flag_en"
android:layout_gravity="center_horizontal"
android:layout_marginTop="5dip"
android:drawablePadding="10dip"
android:textColor="#000000"
android:text="English" />
</RadioGroup>
</LinearLayout>
</ScrollView>
我明白了:
我想在单选按钮和标志之间留出一些空间(边距)(它是可绘制的)。有没有可能?
【问题讨论】:
-
如果您不介意将标志放在文本右侧,则可以使用
android:drawablePadding轻松调整其位置。 -
使用 drawableRight insted of drawableLeft 没有区别。使用它,单选按钮和文本之间没有边距,而不是单选按钮和可绘制之间。
-
嗯..好像你是对的;我已经在 Eclipse 中使用图形布局对 Android 1.6 到 2.2 进行了测试,单选按钮和文本之间存在合理的边距,但从 2.3 开始,空间似乎很小,就像你的图片一样。
-
@DixieFlatline 尝试删除 layout_gravity 并使用 layout_marginTop 这种方法对我有用。
标签: android radio-button drawable margin