【发布时间】:2014-08-14 20:35:27
【问题描述】:
我查看了多个类似的问题,尽管我没有找到适合我的问题的答案。
我有一个在 shape.xml 中定义的可绘制对象
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="@color/bg_color" />
</shape>
我想将其转换为Bitmap对象以执行一些操作,但BitmapFactory.decodeResource()返回null。
这就是我的做法:
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.shape);
我做错了什么? BitmapFactory.decodeResource() 是否适用于 xml 定义的可绘制对象?
【问题讨论】:
标签: android android-drawable xml-drawable