Home > Android > How to have a tiled background

How to have a tiled background

I’m still using in my layout definition the same way to define the background, with a androidbackground parameter, with the path to your repeating background ( actually that was the point : having a consistent way for background, let them be tiled or not )


xml :
<?xml version=”1.0″ encoding=”utf-8″?>
in my drawable directory, I have a back.png file (  the background I want to tile ), and I create this new backrepeat.xml file :

 <?xml version=”1.0″ encoding=”utf-8″?> <bitmap xmlns:android=”http://schemas.android.com/apk/res/android&#8221;

    android:tileMode=”repeat” />
Some points :
* I think my first tries failed because I forgot the ‘xmlns:android’ parameter.
* I tried without the xml version line, and it still works, but I think I will let it be there… Just in case !
* The tilemode can be repeat, mirror, or clamp.
* Although in Java, I could set a different repeat mode for X and Y, I don’t think it is possible in the Xml file. Not that I really care for the moment 🙂
That’s all !
Thanks again Romain !
I know it is your job, as a Android engineer, to evangelise and help us, but several times you really helped me, you were quick to answer, with concise and most useful answers…
Categories: Android
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: