Android的 - 不断变化的状态TextView的变色状态、Android、TextView

由网友(你是我的逃不掉)分享简介:我如何申请颜色上的各种状态的TextView中的(重点,pressed,启用)?How can I apply color on the various states(focused, pressed, enabled) of the TextView?我已经提到这一点: http://developer.andr...

我如何申请颜色上的各种状态的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>
阅读全文

相关推荐

最新文章