gpt4 book ai didi

android - 按钮上的单选按钮文本

转载 作者:太空宇宙 更新时间:2023-11-03 13:35:59 25 4
gpt4 key购买 nike

我正在尝试在 android 中创建一个如下所示的 View :

正文

  • 单选按钮 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>

截图:

Screwed up radio button

最佳答案

问题是设置背景。如果您从 RadioButton 中删除背景并将其保留在 RadioGroup 中,则它具有您正在寻找的效果。通常,将 Button 的背景设置为 everything 会消除按钮外观;在常规 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>

关于android - 按钮上的单选按钮文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7247922/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com