在我的attr.xml
中,我定义descriptor_bg
为:
</declare-styleable>
<attr name="descriptor_bg" format="reference|color" />
</declare-styleable>
并在style.xml
:
<style name="Theme_blue">
<item name="descriptor_bg">@android:color/black</item>
<item name="android:windowNoTitle">true</item>
</style>
我使用了上述属性,例如:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90" />
<solid android:color="@attr/descriptor_bg"/>
<stroke
android:width="2dp"
android:color="@color/blue_stroke_bg" />
但是我遇到了一个例外,例如:
android.content.res.Resources$NotFoundException: File res/drawable-mdpi/descriptor_bg.xml
来自可绘制资源 ID #0x7f020006
java.lang.UnsupportedOperationException: Can't convert to color: type=0x1
File res/drawable-mdpi/descriptor_bg.xml from drawable resource ID #0x7f020006
谁能帮帮我吗?