以LinearLayout为例,它提供的background属性将会将背景图片拉伸,相当难看。事实上我们只需做少量的修改就可以实现web编程中css背景图片的效果。来试试吧。
创建重复的背景图片
在drawable目录下创建一个repeat_bg.xml:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/bg"
android:tileMode="repeat" />
然后在布局的xml文件中可以这样引用:
<LinearLayout
android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/repeat_bg"> </LinearLayout>
Android设置背景图片平铺
原文:http://blog.csdn.net/t80t90s/article/details/41961057