user710502
user710502

Reputation: 11471

Android Bitmap OnDraw

I created a layout in my myviewlay.xml but this is not working, what am i missing?

        protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

       imageBack =  BitmapFactory.decodeResource(getResources(), R.layout.myviewlay, null);
    } 

Upvotes: 0

Views: 2465

Answers (1)

Amplify91
Amplify91

Reputation: 2660

Add this to do the actual drawing:

canvas.drawBitmap(imageBack, x, y, mPaint); //replace x,y,and mPaint with whatever you need to.

However, if you're trying to display an entire layout use setContentView(imageBack) or something similar. It's recommended to do your layout in XML.

Update: Sorry I misunderstood you at first. It looks like you ARE trying to inflate a layout from XML. In that case, in your onCreate(), call setContentView(R.layout.myviewlay);

Upvotes: 2

Related Questions