【问题标题】:RadioButtons and text invisible on device单选按钮和文本在设备上不可见
【发布时间】:2015-10-09 17:54:59
【问题描述】:

我正在使用 Android Studio,我的项目中有一个包含 4 个按钮的单选按钮组的应用程序,用于从我的数据库中选择答案。这些按钮在设备上是不可见的,但仍然可以单击它们,因为它们在单击时显示为绿色。此外,没有为每个答案显示文本,但显示了单选按钮上方 textview 中的问题文本!很混乱。有没有人遇到过这个问题并知道如何解决?这是我的 xml 布局的副本

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:gravity="center_horizontal"
    android:background="@drawable/background">

    <LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:paddingTop="15dip" 
        android:paddingBottom="15dip"
        android:gravity="center_horizontal">

        <ImageView android:id="@+id/logo" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:src="@drawable/logo2" />

    </LinearLayout>

    <LinearLayout android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingTop="5dip"
        android:paddingBottom="5dip"
        android:gravity="center_horizontal">

        <RadioGroup android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:orientation="vertical"
            android:id="@+id/group1">

            <TextView android:layout_width="fill_parent"
                android:layout_height="wrap_content" 
                android:textColor="#ffffff"
                android:textStyle="bold" 
                android:id="@+id/question"/>

            <RadioButton android:checked="false" android:id="@+id/answer1"
                />

            <RadioButton android:checked="false" android:id="@+id/answer2"
                />

            <RadioButton android:checked="false" android:id="@+id/answer3"
                />

            <RadioButton android:checked="false" android:id="@+id/answer4"
                />

        </RadioGroup>

    </LinearLayout>


    <Button android:text="Next"
        android:id="@+id/nextBtn"
        android:layout_width="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_height="wrap_content"
        android:background="@drawable/button_selector"
        android:paddingTop="5dip"
        android:paddingBottom="5dip"
        android:textColor="#ffffff"
        android:layout_gravity="center_horizontal" />

</LinearLayout>

【问题讨论】:

  • 我找不到您更改单选按钮文本颜色的位置。您将 textview 的文本颜色更改为白色...也许您有一个带有黑色文本和黑色图标的黑色 bavkground?
  • 尝试更改您的主视图背景,可能它与您的文本和 RadioButton 背景颜色相同。这就是为什么它们对你来说是隐形的。
  • 我已经厌倦了改变背景,文本在黑色背景上是白色的,文本视图中的上面的文本显示很好,但只是收音机组不可见
  • 刚试过,还是一样的问题
  • 你的 Run code sn-p 按钮有什么作用?它什么也没显示。

标签: android android-studio android-radiogroup


【解决方案1】:

只需用这个替换你的单选按钮,

<RadioButton android:checked="false" android:id="@+id/answer1"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="text 1"
            />

        <RadioButton android:checked="false" android:id="@+id/answer2"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="text 2"
            />

        <RadioButton android:checked="false" android:id="@+id/answer3"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="text 3"
            />

        <RadioButton android:checked="false" android:id="@+id/answer4"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="text 4"
            />

它会起作用的:)

【讨论】:

  • 不幸的是同样的问题:-(这是一个真正的难题,广播组应该显示我数据库中的答案,他们最初确实这样做了,我认为它不可能是数据库,因为问题显示得很好! 只是广播组和答案不可见
  • 在编辑每个按钮后更改了文本颜色,现在正在显示答案,但单选按钮不可见
  • 所以单选按钮组内单选按钮的拇指显示不正确??
  • 是的,它在那里,因为我按下屏幕,它显示为绿色,然后又消失了
  • 如果有帮助,它是一个选择检查按钮
猜你喜欢
  • 1970-01-01
  • 2019-01-16
  • 2014-10-30
  • 1970-01-01
  • 1970-01-01
  • 2019-08-10
  • 2018-03-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多