Android - Textview change color on changing of state

后端 未结 5 1963
滥情空心
滥情空心 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:50

    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

    if your xml is 'res/drawable/abc.xml' then set background as

    android:background="@drawable/abc"
    

    Edited to add color in state xml
    our xml, res/drawable/abc.xml

    
       
    
    
    

    Then declare gray in your res\values\strings.xml

    #808080
    

提交回复
热议问题