我正在尝试根据状态更改TextView样式。我的styles.xml包含:
<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>但是当我将它应用于我的文本视图(style="@drawable/text_ops")时,它不起作用。有什么建议吗?
谢谢
发布于 2011-11-09 20:13:57
据我所知,在安卓系统中只有两个状态列表1.颜色状态列表资源2. StateListDrawable。如果您在其中使用样式,请重新检查文档
有关更多信息,请查看下面的链接
发布于 2011-11-09 20:11:07
问题是代码行style="@drawable/text_ops" this应该是style="@style/text_ops“。
我还没有尝试过使用样式选择器,但如果它是这样工作的,那就太酷了。
https://stackoverflow.com/questions/8064707
复制相似问题