不能使用矢量drawable作为android中的一个位图drawable

时间:2017-05-21 15:18:47

标签: android android-drawable android-vectordrawable

我正在将一个矢量drawable打包在一个位图drawable中并尝试将其用作视图的背景。这成功符合但在运行时崩溃并发现资源未找到异常。

以下是资源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>

但是如果直接使用矢量资源它工作得很好。我在一个位图中打包的原因是当用作视图的背景时不会拉伸位图。我知道可能还有其他一些方法来实现这一点,但是我我想知道为什么这不起作用。

0 个答案:

没有答案