更新时间:2023-02-11 22:56:53
在可绘制对象中创建以下button_text.xml
Create following button_text.xml in drawable
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="#ffff0000"/> <!-- pressed -->
<item android:state_focused="true"
android:color="#ff0000ff"/> <!-- focused -->
<item android:color="#ff000000"/> <!-- default -->
</selector>
将文本视图的textColor更改为:
Change your text view's textColor to:
<TextView
android:id="@+id/txt_bell_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/rihanna_love_the_way_lie"
android:textColor="@color/button_text" //point to that xml
android:textSize="15sp"
android:textStyle="bold"
android:typeface="sans" />
您可以在此处了解有关颜色状态列表的信息.
You can read about color state list here