开发者

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

开发者 https://www.devze.com 2023-02-04 19:26 出处:网络
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

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 th开发者_StackOverflow中文版e 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.


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>


use android:tileMode.

0

精彩评论

暂无评论...
验证码 换一张
取 消