尝试向微调框添加边框时出现运行时错误

时间:2019-04-12 17:00:13

标签: java android

我尝试为微调器添加边框。

这是xml res / drawable / spinner_background.xml。

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item><layer-list>
        <item><shape>
            <stroke android:width="2dp" android:color="#f58218" />
            <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
        </shape></item>
        <item >
            <bitmap android:gravity="right|center" android:src="@drawable/ic_arrow_downward_black_24dp" />
        </item>
    </layer-list></item>
</selector>

这是微调器

  <Spinner
                                android:id="@+id/marketSpinner"
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="8dp"
                                android:background="@drawable/spinner_background"></Spinner>

@ drawable / ic_arrow_downward_black_24dp是矢量资源。

我在运行时收到此错误

Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #9: <bitmap> requires a valid 'src' attribute
        at android.graphics.drawable.BitmapDrawable.updateStateFromTypedArray(BitmapDrawable.java:771)
        at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:731)
        at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1229)
        at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:282)
        at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:196)
        at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1229)
        at android.graphics.drawable.StateListDrawable.inflateChildElements(StateListDrawable.java:188)
        at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:116)
        at android.graphics.drawable.DrawableInflater.inflateFromXml(DrawableInflater.java:130)
        at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1229)
        at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1202)
        at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:715)
            ... 57 more

0 个答案:

没有答案