Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image background - how to repeat image as background rather than stretch it

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.

like image 846
lior Avatar asked Jan 12 '11 09:01

lior


People also ask

How do I make my background image not stretch?

How to fit image without stretching and maintain aspect ratio? Answer: If you want to use the image as a CSS background, there is an elegant solution. Simply use cover or contain in the background-size CSS3 property. contain will give you a scaled-down image.

Can you repeat background image only vertically?

The background-repeat CSS property sets how background images are repeated. A background image can be repeated along the horizontal and vertical axes, or not repeated at all.

What feature is used to control the repetition of an image in the background?

To control the repetition of an image in the background, use the background-repeat property. You can use no-repeat value for the background-repeat property if you do not want to repeat an image, in this case, the image will display only once.


1 Answers

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>
like image 163
C-- Avatar answered Sep 19 '22 13:09

C--