背景图片不重复在Android的布局布局、背景图片、Android

2023-09-12 11:06:42 作者:moveon(离开)

我用下面的code重复图像的背景,但它不工作任何一个可以帮助?

i've used the following code to repeat the image in the background but its not working can any one help?

Layout.xml

Layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/grass_bg"
    >

grass_bg.xml在绘制看起来像这样

grass_bg.xml in drawable looks like this

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

它显示了相同的小图像。它不是重复......

its showing the same small image. its not repeating...

推荐答案

在每次使用时间创建的 grass_bg.xml 副本(即 grass_bg_2.xml )。这为我工作,以保证 TILEMODE 设置时不会丢失时,相同的背景是反复使用。

Create a copy of grass_bg.xml for each time you use it (ie grass_bg_2.xml). This worked for me to assure the tileMode setting was not lost when the same background is used repeatedly.