在res中建立一个color文件夹,在其中新建一个xml(这里为text_color.xml):
1
2
3
4
|
<
item
android:state_pressed
=
"true"
android:color
=
"@color/white"
></
item
>
<
item
android:color
=
"@color/login_footerbutton_n"
></
item
>
</
selector
>
|
然后设置你的TextView属性:
1
2
3
4
5
6
7
8
|
<
TextView
android:id
=
"@+id/textView3"
android:layout_width
=
"wrap_content"
android:layout_height
=
"wrap_content"
android:textColor
=
"@color/text_color"
android:textSize
=
"11dp"
android:clickable
=
"true"
android:text
=
"忘记密码"
/>
|
重点要讲一下的是
clickable属性,默认该属性为false,此时TextView是不可点击的,也就不会有变换颜色的效果。所以要将该属性设为true。