【发布时间】:2017-07-11 21:58:25
【问题描述】:
如何从可绘制的 xml 形状中获取位图。 我做错了什么?
shadow.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="270.0"
android:endColor="@android:color/transparent"
android:startColor="#33000000"
android:type="linear" />
<size android:height="7.0dip" />
</shape>
我从drawable中检索位图的方法:
private Bitmap getBitmap(int id) {
return BitmapFactory.decodeResource(getContext().getResources(), id);
}
当传入的 id 是 shadow.xml 可绘制 id 时,getBitmap() 返回 null。
【问题讨论】:
标签: android