I have an XML drawable file with a stroke, and I also have several bitmaps which I want to apply the stroke to. I tried calling Drawable.draw(canvas), but it throws IllegalStateException
stroke XML:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke android:width="3dp"
android:color="#ffffffff"/>
</shape>
Drawing code:
Drawable strokeDrawable = getResources().getDrawable(R.drawable.stroke);
Bitmap bmp1 = BitmapFactory.decodeResource(getResources(), R.drawable.bmp1);
Canvas canvas = new Canvas(bmp1);
strokeDrawable.draw(canvas);
How should I do this?
Solution: