android - TextView with drawableTop and textcolor -


this textview. has image selector on top.

    <textview         android:id="@+id/icon_live_ticker"          android:layout_width="100dp"         android:layout_height="wrap_content"         android:drawabletop="@drawable/selector_live_ticker"          android:gravity="center"          android:textappearance="?android:attr/textappearancemedium"          android:textstyle="bold"                      android:textsize="10dp"         android:text="@string/text_icon_live_ticker">     </textview>  

the problem is, if set textcolor, there no state changes of image selector see anymore.

can explain why happen?

and solution is, use color-selector textcolor

<?xml version="1.0" encoding="utf-8"?> <selector     xmlns:android="http://schemas.android.com/apk/res/android">     <item         android:state_pressed="false"         android:color="#777777" />     <item         android:state_pressed="true"         android:color="#aaaaaa" /> </selector> 

and modificated textview looks like:

    <textview         android:id="@+id/icon_live_ticker"          android:layout_width="100dp"         android:layout_height="wrap_content"         android:drawabletop="@drawable/selector_live_ticker"          android:gravity="center"          android:textappearance="?android:attr/textappearancemedium"          android:textstyle="bold"                      android:textsize="10dp"         android:textcolor="@drawable/selector_icon_text_color"         android:text="@string/text_icon_live_ticker">     </textview> 

i wrote small post that: http://hello-android.blogspot.com/2011/01/problem-with-textcolor-by-using.html


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -