我有一个单选按钮,文字在左边,实际按钮在右边。
我想添加一个多行字符串作为文本,但当我这样做时,按钮总是对齐文本的中心。有什么办法让我选择它的确切位置吗?
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/white"
>
<RadioButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textSize="@dimen/text_size"
android:minHeight="60dp"
android:text="@string/multilinestring"
android:button="@null"
android:drawableRight="@drawable/btn_radio_holo_light" />
</RadioGroup>
更新:
使用<RadioGroup><RelativeLayout>
似乎可以做到这一点,但是当添加更多的单选按钮时,它们就不再是一个整体了。
我是说:
<RadioGroup>
<RelativeLayout>
<TextView> </TextView>
<RadioButton></RadioButton>
</RelativeLayout>
<RadioButton></RadioButton>
<RadioGroup>
这让我可以在我想要的地方设置按钮,但是2个单选按钮不能作为同一组的一部分。我可以同时点击/选择
发布于 2015-08-17 18:18:50
您可以通过指定按钮位置来更改按钮位置。喜欢
android:button="@null"
android:drawableBottom="@android:drawable/checkbox_off_background"
它将在文本底部绘制按钮。您可以使用更多的选项,如android:drawableRight,android:drawableLeft,android:drawableTop,android:drawableEnd,android:drawableStart,android:drawablePadding,以改变按钮的位置。
https://stackoverflow.com/questions/32056915
复制相似问题