image background - how to repeat an image rather than strech it

by liordav » Wed, 12 Jan 2011 16:57:49 GMT

Sponsored Links
I have an image I want to use as a background to some layout.
the problem is the image contains a texture of slant lines, so if i
use a 1 pixel width image or a 9 patch the image is stretched and the
texture is Twitching, so i can see the slant lines as latitude lines.
I saw that he android emulator uses a similar texture in the progress
bar indeterminate animation, is there a special/simple definition to
order the background image to repeat itself rather than stretch? is
there a way to do it with 9 patch, cause eventualy i also need the
corners to be round.
thanks for the help.


Re: image background - how to repeat an image rather than strech it

by Doug » Thu, 13 Jan 2011 07:26:17 GMT

 See BitmapDrawable and its related xml configuration documentation if
you want to tile an image for the background of a View.


Sponsored Links

Re: image background - how to repeat an image rather than strech it

by Muhammad Ali » Thu, 13 Jan 2011 16:07:05 GMT

 You can create a bitmap in memory, using your own file and draw it in
background. It will help you like the repeat image.


Re: Re: image background - how to repeat an image rather than strech it

by Richard Leggett » Sat, 15 Jan 2011 01:51:25 GMT

 An easy way of making a bitmap repeat is to create an XML file in the drawable 
folder which looks something like this:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="" ;
    android:tileMode="repeat" />

"background" is a PNG in the same folder, it doesn't sound like you need a 9 
patch in this case. Simply assign @drawable/repeatingbackground or whatever you 
called the file, in place of the original bitmap. 

As for rounding corners, you can subclass the view you are rendering (let's say 
an ImageView) and use clipping to mask the corners, there are a few examples 

I'm presenting techniques here that are more generalised and re-useable and not 
a specific one-off which could be better performance-wise (so if you are making 
a component that's like a progress bar, you'd do this clipping and 
repeat-bitmap drawing in the onDraw() rather than increasing rendertime by 
compositing a separate RoundedImageView and a repeatable BitmapDrawable 
described above).



Other Threads

1. Brp harga hero second?

Kelengkapan lengkap, baru diapakai sebulan. Warna putih.

Kira kira brp harga yg pantas?

Sent from my BlackBerry smartphone from Sinyal Bagus XL, Nyambung Teruuusss...!
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to

To request to subscribe to this group:


2. Automatic permissions in my T-Mobile G1

When I run any application from Eclipse on my real G1 device (a retail
one, this is not a dev phone), I am granted the READ_PHONE_STATE and
WRITE_EXTERNAL_STORAGE even if i don't declare them in the
AndroidManisfest.xml. I actually can call TelephonyManager.getDeviceID
() to retrieve the IMEI and I see these permissions in Settings ->
I don't have this behavior in the emulator.
Does anyone have the same "problem" ?


3. ImageView with zoom, or just use WebView somehow?

4. tanya cymogen 4.2.5 unt dream, bagus n stabil udaan???? ada yg uda coba?? share :)

5. tanya pengguna htc dream

6. Fwd: [Mobile-App-Developers] Google Mobile Blog

7. how to get domain name