14

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

tinti
  • 1,455
  • 8
  • 23
  • 39

2 Answers2

55

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" >
Zeba
  • 3,041
  • 1
  • 28
  • 39
0

You can use the android:background as a 9patch image to automatically stretch.

9patch on Android Dev site

Davos555
  • 1,974
  • 15
  • 23