Android的 - 不断变化的状态TextView的变色 [英] Android - Textview change color on changing of state
问题描述
我如何申请颜色上的各种状态的TextView中的(重点,pressed,启用)?
How can I apply color on the various states(focused, pressed, enabled) of the TextView?
我已经提到这一点: http://developer.android。 COM /参考/安卓/内容/ RES / ColorStateList.html ,但不知道如何申请颜色状态列表中的TextView?或者是有任何其他方式来做到这一点?
I have already referred this: http://developer.android.com/reference/android/content/res/ColorStateList.html , but do not know how can I apply color state list to the TextView? or is there any other way to do so ?
我想改变背景颜色。
推荐答案
新建一个新的 XML
(在绘制
文件夹)。与颜色,你可以为每个事件状态指定图片
你可以,你可以设置此XML作为你的背景
Create new a new xml
(in the drawable
folder). with the color you can specify image for each event state
and you can you can set this xml as you background
如果你的XML是 RES /绘制/ abc.xml
,然后设置背景
if your xml is 'res/drawable/abc.xml
' then set background as
android:background="@drawable/abc"
编辑,以增添色彩状态XML
我们的XML, RES /绘制/ abc.xml
Edited to add color in state xml
our xml, res/drawable/abc.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:drawable="@color/gray" />
</selector>
然后在宣布灰色的资源\值\的strings.xml
<color name="gray">#808080</color>
这篇关于Android的 - 不断变化的状态TextView的变色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!