6

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769
lior
  • 61
  • 1
  • 1
  • 2
  • 1
    Is this a question related to Android? If so, tag the question as such. If not, perhaps you could give a clue about what technology you're working with. – Damien_The_Unbeliever Jan 12 '11 at 09:04

2 Answers2

29

You would probably want to take a look at tile mode as Xandy answered. Here is some code for your reference which is used by me.

repeat.xml

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

main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/repeat">
</LinearLayout>
C--
  • 16,393
  • 6
  • 53
  • 60
6

use android:tileMode.

xandy
  • 27,357
  • 8
  • 59
  • 64