元の内で定義されたいくつかの状態の動作を変更するために、のXML定義?attr/selectableItemBackgroundBorderless
内で参照しようとしています。StateListDrawable
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/transparent" android:state_pressed="false" />
<item android:drawable="?selectableItemBackgroundBorderless" />
</selector>
しかし、これはクラッシュを引き起こします:
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 0: TypedValue{t=0x2/d=0x7f040298 a=-1}
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:946)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:177)
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:122)
at android.graphics.drawable.DrawableInflater.inflateFromXmlForDensity(DrawableInflater.java:142)
at android.graphics.drawable.Drawable.createFromXmlInnerForDensity(Drawable.java:1332)
at android.graphics.drawable.Drawable.createFromXmlForDensity(Drawable.java:1291)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:833)
... 46 more
私が理解していないのは、LayerDrawable
コード的に同じことをしているように見える で実際に動作する理由です:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/transparent" />
<item android:drawable="?selectableItemBackgroundBorderless" />
</layer-list>
?attr/
a内で aを使用することは可能<selector>
ですか?