Background of View non-scaled?

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

Background of View non-scaled?

Postby TheChosen » Mon Aug 03, 2009 2:10 pm

By setting the background drawable of a View this background image gets stretched automatically to fill the space of the View.

Is there a way to prevent this stretching behaviour? I would like to keep the size of the image and have it centered in the background of the View.
TheChosen
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Tue Jan 06, 2009 7:18 pm
Location: Germany

Top

Postby Emmanuel7 » Mon Aug 03, 2009 11:34 pm

Hi,

Some time ago, I was wondering about something quite similar : how to prevent the stretching behaviour, but what I wanted was to repeat the background, not to have it centered.

I don't fully remind everything, so I don't know how to have a centered background image, but you can find about my solution to have a tiled background here on my blog :
http://androidblogger.blogspot.com/2009/01/how-to-have-tiled-background.html
http://androidblogger.blogspot.com/2009/01/how-to-have-tiled-background-cont.html

Hope it can be a base for help,
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Postby arams » Tue Aug 04, 2009 7:36 am

Thanks Emmanuel....

when i try your (blogspot refer) code i got some errors....could you post the correct code in this page to referrence....
Thanks Again
arams
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Fri May 08, 2009 7:45 am

Postby Emmanuel7 » Tue Aug 04, 2009 5:02 pm

Hi,


My code was certainly for Android 1.1, so it may not be working anymore, but some replacement functions should exist.

But for the XML part ( the 2nd link I gave ), it is exactly what I have in my game "Word Prospector", and it's still in place, and still working OK !
Emmanuel7
Senior Developer
Senior Developer
 
Posts: 164
Joined: Fri Dec 12, 2008 2:17 am
Location: Paris

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 5 guests