【发布时间】:2009-11-09 10:02:59
【问题描述】:
我有一个图案(.png 图像 4x4px)并且必须用它填充布局。
有人知道怎么做吗?
如果我只是选择可绘制对象作为图像的背景,它会被拉伸;相反,它需要沿 x 和 y 轴重复。
【问题讨论】:
标签: android background design-patterns
我有一个图案(.png 图像 4x4px)并且必须用它填充布局。
有人知道怎么做吗?
如果我只是选择可绘制对象作为图像的背景,它会被拉伸;相反,它需要沿 x 和 y 轴重复。
【问题讨论】:
标签: android background design-patterns
Here 是一个非常好的解释:
将“back.png”图像放在“drawable”文件夹中。然后像这样创建一个可绘制的“backrepeat.xml”:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/back"
android:tileMode="repeat" />
在你的布局中,添加android:background="@drawable/backrepeat":
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/MainLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/backrepeat">
</LinearLayout>
与许多 Android 良好做法/实用技巧一样,它可以追溯到 Romain Guy。
【讨论】: