TextView的STATE_ pressed / state_focused / state_selected作风转变 [英] TextView state_pressed/state_focused/state_selected style change

查看:693
本文介绍了TextView的STATE_ pressed / state_focused / state_selected作风转变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变根据其状态一个TextView风格。 我的styles.xml包含:

I'm trying to change a TextView style based on its state. My styles.xml contains:

<style name="text_normal_ops">  
    <item name="android:gravity">left</item>  
    <item name="android:textColor">@color/text_usual_color</item> 
    <item name="android:textStyle">bold</item>  
</style>  
<style name="text_normal_ops_pressed">  
    <item name="android:gravity">left</item>  
    <item name="android:textColor">@color/text_pressed</item>  
    <item name="android:textStyle">bold</item>  
</style>

我的选择( text_ops.xml )的定义是:

<selector xmlns:android="http://schemas.android.com/apk/res/android">  
    <item android:state_pressed="true" style="@style/text_normal_ops_pressed" />  
    <item android:state_focused="true" style="@style/text_normal_ops_pressed" />  
    <item android:state_selected="true" style="@style/text_normal_ops_pressed" />  
    <item style="@style/text_normal_ops"/>  
</selector>

但是,当我将此运用到我的TextView(风格=@可绘制/ text_ops)这是行不通的。 任何提示吗?
谢谢

But when I apply this to my textview (style="@drawable/text_ops") it does not work. Any tips?
Thanks

推荐答案

在Android的按我所知,只有两个国家列表1.颜色状态列表资源2. StateListDrawable。如果您在使用它的风格,那么请重新检查文档

In android as per my knowledge there is only two state-list 1. Color State List Resource 2. StateListDrawable. If you are using style in it then please recheck the doc

请查看以下链接了解更多信息

Please check below link for more info

  1. <一个href="http://developer.android.com/guide/topics/resources/color-list-resource.html">http://developer.android.com/guide/topics/resources/color-list-resource.html
  2. <一个href="http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList">http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList
  1. http://developer.android.com/guide/topics/resources/color-list-resource.html
  2. http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

这篇关于TextView的STATE_ pressed / state_focused / state_selected作风转变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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