我正在尝试在android中创建如下视图:
文本
>单选按钮1
> …
> …
我以为它很简单,但是至少在布局预览和仿真器中,我看到RadioButton的文本出现在实际单选按钮(圆圈)的顶部,请参见所附的屏幕截图.我猜这是一件很琐碎的事,但是我对重力和我能想到的所有其他设置一无所知. Android 3.1如果重要的话.
这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView android:id="@+id/question_text"
android:textColor="@color/primary_gray"
android:layout_width="match_parent"
android:text="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
android:layout_height="wrap_content"/>
<RadioGroup android:id="@+id/multiple_choice_one_answer_group"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:background="@color/primary_gray"
android:textColor="@color/black"
android:textSize="10sp"
android:text="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" />
</RadioGroup>
</LinearLayout>
屏幕截图:
解决方法:
问题是设置背景.如果您从RadioButton中删除背景,并将其保留在RadioGroup中,它将具有您想要的效果.通常,将Button的背景设置为所有内容都会删除按钮的外观.在常规按钮上尝试一下,您会看到的.这是因为Button的背景已经设置为某种东西,并且您将其替换为纯色.
尝试以下方法:
<RadioGroup android:id="@+id/multiple_choice_one_answer_group"
android:background="@color/primary_gray"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RadioButton
android:textColor="@color/black"
android:textSize="10sp"
android:text="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" />
</RadioGroup>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。