简体   繁体   English

单选按钮更改文本颜色

[英]radiobutton change text color

I cant change the text color in my radiobutton: 我无法更改单选按钮中的文本颜色:

  <RadioGroup
                        android:gravity="center"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:orientation="horizontal"
                        android:color = "#000000"
                    >

                        <RadioButton 
                            android:id="@+id/contact_yes"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:color = "#000000"
                            android:text="@string/yes" />

                        <RadioButton 
                            android:id="@+id/contact_no"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:color = "#000000"
                            android:text="@string/no" />
                </RadioGroup>

It's always white, and I would like to change to black? 它总是白色的,我想换成黑色吗?

Thank you in advance 先感谢您

例如,该属性为textColor="#ffff00ff"

android:textColor="#000000"

or 要么

android:textColor="@android:color/black"

use textColor to change color of text 使用textColor更改文本的颜色

<RadioButton android:id="@+id/contact_yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:color = "#000000"
android:text="@string/yes" />

Try this: 尝试这个:

<RadioButton 
android:id="@+id/contact_yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="@string/yes" />

You can use android:textColor method to do that. 您可以使用android:textColor方法来做到这一点。

An example is android:textColor="#00000000" 一个示例是android:textColor =“#00000000”

In #00000000 the two left bit is transparent bit . 在#00000000中,左两位是透明位。 #00 ( transparent ) 00 ( Red Color) 00 ( Green color) 00 ( Blue color). #00( 透明 )00( 红色 )00( 绿色 )00( 蓝色 )。 they are hex. 他们是十六进制。

To more details about transparent bit see Set transparent background . 有关透明位的更多详细信息,请参见设置透明背景

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM