1. android:textColor="@drawable/textview_selector"
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello_world"
android:textColor="@drawable/textview_selector"/>
2. 在res/drawable下,textview_selector.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#323232" android:state_pressed="false"></item>
<item android:color="#4c000000" android:state_pressed="true"></item>
<item android:color="#4c000000" android:state_selected="true"></item>
<item android:color="#4c000000" android:state_focused="true"></item>
</selector>
3. 获取到TextView实例,添加点击事件