【问题标题】:Android - Radio Button Not Showing its TextAndroid - 单选按钮不显示其文本
【发布时间】:2011-10-12 18:41:18
【问题描述】:

我的应用有一个单选按钮组作为相对布局的一部分。我的问题是 RadioButtons 没有显示它们的文本。我得到的只是按钮本身。

这是 XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/setupTabLayout"
    android:scaleType="fitXY"
    android:background="#ffffff" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:baselineAligned="true" 
    android:orientation="vertical">

    <TextView android:id="@+id/textView1" 
        android:text="Total Points" 
        android:textColor="#000000"
        android:textSize = "30sp"
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:paddingBottom="5px"
        android:layout_gravity="top"
        android:layout_alignParentLeft="true"
        ></TextView>

      <EditText android:id="@+id/editTextTotal" 
        android:text="" 
        android:digits="-0123456789."
        android:windowSoftInputMode="stateVisible"
        android:focusable="true"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignTop="@+id/textView1" 
        android:layout_alignBottom="@+id/textView1"
        android:layout_toRightOf="@+id/textView1" 
    ></EditText>

    <RadioGroup android:id="@+id/radioGroup1"  
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_alignParentLeft="true"
        android:layout_above="@+id/textView2"
    > 

        <RadioButton android:id="@+id/radioButton1" 
            android:checked="true" 
            android:text="Points" 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"  
        ></RadioButton>

        <RadioButton android:id="@+id/radioButton2" 
            android:text="Points" 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content"
            android:layout_toRightOf="@+id/radioButton1" 
        ></RadioButton>

    </RadioGroup>   

    <TextView android:id="@+id/textView2" 
        android:text="Points Per = " 
        android:textColor="#000000"
        android:textSize = "30sp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:paddingBottom="5px"
        android:layout_above="@+id/numberPadLayoutContainer"
        android:layout_alignParentLeft="true"
    ></TextView>

    <EditText android:id="@+id/editTextPoints" 
        android:text="" 
        android:digits="-0123456789."
        android:windowSoftInputMode="stateVisible"
        android:focusable="true"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignTop="@+id/textView2" 
        android:layout_alignBottom="@+id/textView2"
        android:layout_toRightOf="@+id/textView2" 
    ></EditText>

    <include layout="@layout/numerickeyboard" />

</RelativeLayout>  

任何想法为什么文本没有显示?

【问题讨论】:

    标签: android xml text radio-button


    【解决方案1】:

    您的Layout 背景是白色的,RadioButtons 上的文字也是白色的。它们显示在你看不到的地方。

    您可以尝试设置android:textColor="#000" 使文本变黑。

    【讨论】:

    • 啊……嗯,这是一个无聊的时刻。有趣的是,当所有其他文本控件的默认颜色似乎是浅灰色时,默认颜色是白色。谢谢你。 :-)
    猜你喜欢
    • 2015-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多