Color types not allowed (at ‘drawable’ with value ‘#f0f0f0’)

今天在做背景的时候,背景selector里加了如下代码:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="#f0f0f0"/>
    <item android:state_pressed="false" android:drawable="@android:color/white"/>
    <item android:drawable="@android:color/white"/>
</selector>

AS编译报错:Color types not allowed (at ‘drawable’ with value ‘#f0f0f0’)

到colors.xml定义后引用正常:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true" android:drawable="@color/color_study_after"/>
    <item android:state_pressed="false" android:drawable="@android:color/white"/>
    <item android:drawable="@android:color/white"/>
</selector>

你可能感兴趣的:(android,drawable)