我翻阅了多个类似的问题,尽管我还没有找到合适的答案。
我有一个drawable,定义在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。
This is how I'm doing it:
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.shape);
我做错了什么?替换代码1】是否适用于xml定义的drawables?