我在位图绘图中打包了一个可绘制的向量,并试图将它作为view.This成功执行的背景,但是在运行期间崩溃,资源没有找到异常。
以下是资源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_水果_沙拉是一个矢量资源。
用于布局的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>但是如果向量资源被直接使用,它可以工作fine.The,因为我在位图中打包的原因是,当使用位图作为视图的背景时,不会拉伸位图,我知道可能还有其他一些方法来实现这一点,但我想知道为什么这样做不起作用。
发布于 2018-02-26 12:54:36
创建向量资产的等效png文件是有帮助的。使用File->New->Image菜单,并在路径中设置您的向量可绘制地址。
https://stackoverflow.com/questions/44098492
复制相似问题