Android - Textview change color on changing of state

后端 未结 5 2009
滥情空心
滥情空心 2020-11-30 11:14

How can I apply color on the various states(focused, pressed, enabled) of the TextView?

I have already referred this: http://developer.android.com/reference/android/

5条回答
  •  甜味超标
    2020-11-30 11:37

    create xml under res/color dir.

    example file name : selector_white_gray.xml

    
    
         
         
    
    

    you can add more states. you can use color code like "#ffffff" instead of predefined "@color/White". Becarefull, use android:color not android:drawable. this example changes color of text when pressed on it. set the textColor attribute to selector above.

    
    
    

提交回复
热议问题