【发布时间】:2022-01-12 06:37:57
【问题描述】:
我为按钮文本颜色创建了一个自定义选择器:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?android:attr/textColorPrimary" android:state_enabled="true" />
<item android:alpha="0.38" android:color="?android:attr/textColorPrimary" />
</selector>
但是,我想在夜间主题中使用?android:attr/textColorPrimary,在白天主题中使用?android:attr/colorPrimary。我怎样才能做到这一点?
【问题讨论】:
-
你应该使用样式(主题)而不是选择器,你可以创建textcolor样式并设置为xml按钮。
标签: android android-xml android-button android-theme android-styles