我正在将一个矢量可绘制对象打包到位图可绘制对象中,并尝试将其用作视图的背景。这个编译成功了,但在运行时崩溃并显示资源未找到异常。
以下是资源xml文件:
以下是资源xml文件:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_fruit_salad"
android:tileMode="disabled"
android:gravity="center">
</bitmap>
其中@drawable/ic_fruit_salad是矢量资源。
布局的xml:
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_listofitems"
android:background="@drawable/background_fruit_salad"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
但是,如果直接使用矢量资源,则可以正常工作。我将其打包成位图的原因不是为了在视图背景中拉伸位图。我知道可能还有其他方法来实现这一点,但我想知道为什么这样做不起作用。