私の問題に対する適切な答えが見つかりませんでしたが、複数の同様の質問に目を通しました。
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 で定義されたドローアブルに適用できますか?