Android设置背景图片平铺

以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> 


版权所有,如需转载,注明出处,谢谢合作。沈阳--斌子。

注明:QQ技术交流群:108614806   感兴趣的加一下。


 

posted @ 2012-04-17 13:27  志强思密达  阅读(157)  评论(0编辑  收藏  举报