我已经从Google IO Schedule应用程序源代码中 (https://github.com/google/iosched) 复制了一个文件,即
selected_navdrawer_item_background.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/backgroundColor">
<shape>
<solid android:color="#12000000" />
</shape>
</item>
<item android:drawable="?android:selectableItemBackground"/>
</layer-list>
我想用这个来突出显示NavigationDrawer中当前选定的项目。我的问题是,当我启动我的应用程序时,它会抛出一个异常。
我认为这是重要的一行。
caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #22:
<item> tag requires a 'drawable' attribute or child tag defining a drawable
第22行是这一行
<item android:drawable="?android:selectableItemBackground"/>
我不知道问题出在哪里,我从源代码中复制过来,没有进行任何调整。但是在他们的应用程序中可以正常工作。
我尝试将?android:selectableItemBackground
更改为?attr/selectableItemBackground
,但它给我相同的异常。
我似乎找不到其他建议的解决方案。
如果有人知道是什么原因导致这个问题,请帮助我。