安卓设置背景图平铺,同时设置背景色须要在drawable中新建一个background_line_pantone.xml:android
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <!--背景色--> <item> <shape> <solid android:color="#7BB137" /> </shape> </item> <!--背景图平铺--> <item> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@mipmap/line" android:tileMode="repeat" /> </item> </layer-list>
而后再须要用到的地方使用 code
android:background="@drawable/background_line_pantone"xml
进行设置.图片
若是只须要平铺背景图片,则xml中只须要第二个item中的bitmap便可ip