【发布时间】:2015-11-25 13:16:44
【问题描述】:
我有一个带有标签和 RadioGroup 的 RelativeLayout,我希望标签的基线和 RadioGroup 的 RadioButton 子项对齐。我的代码是:
<TextView android:id="@+id/hi"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="Hi"
android:textAppearance="@style/TextAppearance.AppCompat.Display2"
/>
<RadioGroup
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_toRightOf="@id/hi"
android:layout_alignBaseline="@id/hi">
<RadioButton
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="There"/>
</RadioGroup>
相反,我得到的是 RadioGroup 的顶部与标签的基线对齐,如下所示:
如何获得我想要的行为?我绝对不想要任何硬编码的边距或中心对齐,我想对齐基线。
似乎 View.getBaseline 应该报告基线相对于视图顶部的位置,如果该方法为 RadioGroup 返回 0,则可以解释我看到的行为。事实上,RadioGroup 及其基类 LinearLayout 似乎都没有定义该方法。但也许,我忽略了一些东西。
【问题讨论】:
标签: android