【发布时间】:2016-09-21 08:44:07
【问题描述】:
我已经创建了一个选择器:
btn_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- pressed -->
<item android:drawable="@drawable/btn_bg_pressed" android:state_pressed="true" />
<!-- focused -->
<item android:drawable="@drawable/btn_bg_focused" android:state_focused="true" />
<!-- default -->
<item android:drawable="@drawable/btn_bg_default" />
</selector>
btn_bg_pressed.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@color/btn_pressed"/>
</shape>
btn_bg_focused.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="@color/reality_fix_yellow"/>
</shape>
btn_bg_default.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="2dp"
android:color="@color/btn_default_border_color" />
</shape>
我想在焦点改变时更改text color 按钮。我尝试添加 android:color="color_code" 和 android:textColor="color_code" 但失败了。
请帮助我如何使用选择器更改按钮的文本颜色?
【问题讨论】:
-
添加
-
@Anas Azeem 你在下面看到我的答案了吗。
标签: android xml android-tv android-selector