Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 棒棒糖颜色选择器始终为红色,带有自定义属性_Android_Colors_Attributes_Selector - Fatal编程技术网

Android 棒棒糖颜色选择器始终为红色,带有自定义属性

Android 棒棒糖颜色选择器始终为红色,带有自定义属性,android,colors,attributes,selector,Android,Colors,Attributes,Selector,颜色选择器在Android棒棒糖(我在不同的设备上尝试过)中工作不正常,总是红色而不是我指定的颜色。它在牛轧糖、奥利奥、馅饼中效果很好 属性: <resources> ... <attr name="buttonIconColorEnabled" format="color"/> <attr name="buttonIconColorDisabled" format="color"/> </resources> <s

颜色选择器在Android棒棒糖(我在不同的设备上尝试过)中工作不正常,总是红色而不是我指定的颜色。它在牛轧糖、奥利奥、馅饼中效果很好

属性:

<resources>
    ...
    <attr name="buttonIconColorEnabled" format="color"/>
    <attr name="buttonIconColorDisabled" format="color"/>
</resources>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    ...
    <item name="buttonIconColorEnabled">@color/white</item>
    <item name="buttonIconColorDisabled">@color/white</item>
</style>
<style name="AppTheme.PositiveButton" parent="AppTheme">
    ...
    <item name="buttonIconColorEnabled">@color/greenDark</item>
    <item name="buttonIconColorDisabled">@color/white</item>
</style>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?buttonIconColorEnabled" android:state_enabled="true" />
<item android:color="?buttonIconColorDisabled" android:state_enabled="false" />

...
应用程序主题样式:

<resources>
    ...
    <attr name="buttonIconColorEnabled" format="color"/>
    <attr name="buttonIconColorDisabled" format="color"/>
</resources>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    ...
    <item name="buttonIconColorEnabled">@color/white</item>
    <item name="buttonIconColorDisabled">@color/white</item>
</style>
<style name="AppTheme.PositiveButton" parent="AppTheme">
    ...
    <item name="buttonIconColorEnabled">@color/greenDark</item>
    <item name="buttonIconColorDisabled">@color/white</item>
</style>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?buttonIconColorEnabled" android:state_enabled="true" />
<item android:color="?buttonIconColorDisabled" android:state_enabled="false" />

...
@颜色/白色
@颜色/白色
特定按钮样式:

<resources>
    ...
    <attr name="buttonIconColorEnabled" format="color"/>
    <attr name="buttonIconColorDisabled" format="color"/>
</resources>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    ...
    <item name="buttonIconColorEnabled">@color/white</item>
    <item name="buttonIconColorDisabled">@color/white</item>
</style>
<style name="AppTheme.PositiveButton" parent="AppTheme">
    ...
    <item name="buttonIconColorEnabled">@color/greenDark</item>
    <item name="buttonIconColorDisabled">@color/white</item>
</style>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?buttonIconColorEnabled" android:state_enabled="true" />
<item android:color="?buttonIconColorDisabled" android:state_enabled="false" />

...
@颜色/深绿色
@颜色/白色
颜色选择器:

<resources>
    ...
    <attr name="buttonIconColorEnabled" format="color"/>
    <attr name="buttonIconColorDisabled" format="color"/>
</resources>
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
    ...
    <item name="buttonIconColorEnabled">@color/white</item>
    <item name="buttonIconColorDisabled">@color/white</item>
</style>
<style name="AppTheme.PositiveButton" parent="AppTheme">
    ...
    <item name="buttonIconColorEnabled">@color/greenDark</item>
    <item name="buttonIconColorDisabled">@color/white</item>
</style>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?buttonIconColorEnabled" android:state_enabled="true" />
<item android:color="?buttonIconColorDisabled" android:state_enabled="false" />

我认为这不是我使用哪种上下文的问题,因为它是Activitie的上下文(androidx.appcompat.app.AppCompatActivity)

有没有办法让棒棒糖起作用?提前谢谢