在我的 android 应用程序中使用单选按钮选择屏幕 View 。我希望单选按钮水平对齐。我尝试了如下所示的布局 xml。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Views"
android:paddingLeft="10dp"
android:textSize="20sp"
/>
<RadioGroup
android:id="@+id/radioView"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:measureWithLargestChild="true"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radioViewSingle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableRight="@drawable/single"
android:layout_weight="1"
android:checked="true" />
<RadioButton
android:id="@+id/radioView2by2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableRight="@drawable/view2x2" />
<RadioButton
android:id="@+id/radioView3by3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableRight="@drawable/view3x3" />
<RadioButton
android:id="@+id/radioView4by4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableRight="@drawable/view4x4" />
</RadioGroup>
</LinearLayout>
但我期待低于输出
提前致谢
最佳答案
不使用 android:drawableRight,而是使用 android:drawableLeft。
我刚刚测试了这个,它按预期工作
关于android - 如何调整android中单选按钮之间的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35313174/