I’m tryin to draw a shape on a canvas under all buttons.
Here’s the code:
Paint paint = new Paint(); paint.setColor(R.color.Kolor); View view; LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.menu_glowne, null); Canvas can = new Canvas(Bitmap.createBitmap(300, 300, Bitmap.Config.ARGB_8888)); can.drawRect(0, 0, 200, 200, paint); setContentView(view); view.draw(can);
Don’t know why I’m still getting the layout without anything drawn underneath.
Any ideas on what I’m doing wrong?
Thanx in advance!
In your example you are drawing the view on your canvas rather than on canvas of the view.
You should use a simple approach, don’t inflate your layout but load it normally, then find the root container and set its background. Something like this:
main layout: