The good way to draw a Drawable on a canvas is not decoding it yourself but leaving it to the system to do so:
Drawable d = getResources().getDrawable(R.drawable.foobar, null);
d.setBounds(left, top, right, bottom);
d.draw(canvas);
This will work with all kinds of drawables, not only bitmaps. And it also means that you can re-use that same drawable again if only the size changes.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…