如何更改按钮的文本颜色? [英] How do I change the text color of a Button?

查看:154
本文介绍了如何更改按钮的文本颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何改变一个按钮的文本颜色?

How do I change the text color of a Button?

推荐答案

试试这个:

button.setTextColor(getApplication().getResources().getColor(R.color.red)); //TAKE DEFAULT COLOR

button.setTextColor(0xff0000); //SET CUSTOM COLOR 

button.setTextColor(Color.parseColor("#ff0000")); 

和XML:

<Button android:id="@+id/mybtn" 
        android:text="text textx "  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"  
        android:textStyle="bold" 
        android:textColor="#ff0000" />  <-- SET TEXT COLOR HERE -->

这篇关于如何更改按钮的文本颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆