【发布时间】:2014-06-04 19:08:15
【问题描述】:
这是我的 Android 布局文件中的 XML 部分,它应该生成一个 RadioGroup,其中包含三个 RadioButtons:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radbtnAlways"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="@string/radiobutton_Always" />
<RadioButton
android:id="@+id/radbtnNever"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/radiobutton_Never" />
<RadioButton
android:id="@+id/radbtnCost_Change"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/radiobutton_Cost_Change" />
</RadioGroup>
</LinearLayout>
但是,我所看到的这些小部件应该在的位置只是科罗拉多州的蓝色轮廓 - 它太大了,并且没有显示单选按钮:
为什么我的 RadioGroup 这么大,为什么 RadioButton 会模仿 George Jones?
更新
在回答 CommonsWare 时,它在模拟器中看起来是这样的(几乎相同):
【问题讨论】:
-
如果您的屏幕截图来自一些图形预览,请在设备或模拟器上尝试。如果您的屏幕截图来自设备或模拟器,请使用 Hierarchy View(模拟器)或
uiautomatorviewer(设备)来更好地了解正在发生的事情。话虽如此,使用android:layout_weight控制高度与您的高度为wrap_content是不一致的。 -
它在设计时来自 Droidio。从 RadioButtons 中删除 layout_weight 没有任何区别。
-
能否请您发布整个 xml 代码?
标签: android android-layout android-linearlayout android-radiogroup android-radiobutton