Yesterday, I was attempting to add a background to my DrawingView
- something which IMHO should be ridiculously simple. Yet, after trying to various combinations of Bitmap
, Drawable
even ImageView
types, nothing worked. Although you can do it directly in the XML, I had my DrawingView
defined in Java file rather than XML. In the end, I figured out a way do it using assests:
1 2 3 4 5 6 7 |
dv = new DrawingView(this, mPaint); try { dv.setBackgroundDrawable(Drawable.createFromStream(getAssets().open("cube.png"), null)); } catch (IOException e) { e.printStackTrace(); } setContentView(dv); |