Android的:如何创建模式的背景是什么? [英] Android: how to create a background from pattern?
本文介绍了Android的:如何创建模式的背景是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个模式(PNG图片4x4px),并与它来填充版面。
I have a pattern (.png image 4x4px) and have to fill the layout with it.
有谁知道如何做到这一点?
Does anyone know how to do this?
如果我只需选择绘制作为背景的图像,它被拉伸;代替它需要被沿着x和y轴重复
If I simply select the drawable as a background the image, it is stretched; instead it needs to be repeated along the x and y axis.
推荐答案
的在这里是一个非常好的解释:
Here is a really nice explanation:
把你的back.png图像上绘制的文件夹。然后创建一个可绘制的backrepeat.xml这样的:
Put your "back.png" image on "drawable" folder. Then create a drawable "backrepeat.xml" like that:
<?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:背景=@绘制/ 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良好做法/方便的技巧的情况下,它可以追溯到罗曼盖伊。
As is the case with many Android good practices/handy tricks, it can be traced back to Romain Guy.
这篇关于Android的:如何创建模式的背景是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文