我有一个带有笔划的 XML 可绘制文件,并且我还有几个要应用笔划的位图。我尝试调用 Drawable.draw(canvas),但它抛出 IllegalStateException
笔画 XML:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="3dp"
android:color="#ffffffff"/>
</shape>
绘图代码:
Drawable strokeDrawable = getResources().getDrawable(R.drawable.stroke);
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.bmp1);
Canvas canvas = new Canvas(bmp1);
strokeDrawable.draw(canvas);
我该怎么做?