How to change color of the text in TextView on hover like in css?

前端 未结 1 1380
滥情空心
滥情空心 2020-12-16 19:24

How to change color of the text in TextView on hover like in css with selector? I know for button to define selector with items



        
相关标签:
1条回答
  • 2020-12-16 19:57

    Add that selector as a resource file (res/color/text_color.xml)

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_focused="true" android:color="@color/focused_text_color"/>
        <item android:state_pressed="true" android:state_enabled="false" android:color="@color/pressed_text_color" />
        <item android:state_enabled="false" android:color="@color/disabled_text_color" />
        <item android:color="@color/default_text_color"/>
    </selector>
    

    And use it:

    android:textColor="@color/text_color"
    
    0 讨论(0)
提交回复
热议问题