Quick question about canvas

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Quick question about canvas

Postby isaackearl » Wed Jan 07, 2009 1:18 am

i have a simple program i'm working on and right now I have a background color set using

canvas.drawColor(int);

i'm just wondering if there is a simple way to set a background image rather then just a color. And if someone could point me in the right direction.

Thanks
isaackearl
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Nov 25, 2008 8:09 pm

Top

Postby Quetzalcoatl » Wed Jan 07, 2009 11:34 am

Stick a suitable image in your res/drawable folder.

Make a suitable member of your view

Code: Select all
private Drawable mBackgroundImage;        //background image bmp


& in your View's constructor


Code: Select all
mBackgroundImage = getResources().getDrawable(YOUR_IMAGE);
        this.setBackgroundDrawable(mBackgroundImage);

:D
Image
Quetzalcoatl
Senior Developer
Senior Developer
 
Posts: 129
Joined: Sat Oct 18, 2008 8:21 pm
Location: near Manchester, UK

Postby isaackearl » Wed Jan 07, 2009 7:27 pm

thanks, worked like a charm.
isaackearl
Junior Developer
Junior Developer
 
Posts: 20
Joined: Tue Nov 25, 2008 8:09 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests