在drawable目錄下建立一個repeat_bg.xml:android
<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/asdfg" android:tileMode="repeat" > </bitmap>
tileMode 屬性就是用於定義背景的顯示模式:web
disabled 默認值,表示不使用平鋪佈局
clamp 複製邊緣色彩spa
repeat X、Y 軸進行重複圖片顯示,也就是咱們說要說的平鋪code
mirror 在水平和垂直方向上使用交替鏡像的方式重複圖片的繪製orm
在佈局的xml文件中background="@drawable/repeat_bg"便可。xml