Alex Rivera | Logout

Android image background repeat

Asked 2012-02-14T14:52:43.107
15

I have a image used for a LinearLayout background Let's say image has 20x100 px I want to make the image repeat only on x axes ... something like this in css

background-repeat:repeat-x;

The LinearLayout is kinda big (1024 x 680 px) so my image will cover the entire width but only in the top (the rest of 580 px of height will be transparent) I hope i was clear Thanks

Edit
Report

1 Answer

56

try using android:tileMode

create background.xml in drawable folder as:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
  android:src="@drawable/bg" 
  android:tileMode="repeat" />  

and then use it in your layout xml as:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >
answered 2012-06-07T07:06:48.707

Your Answer