安卓設置背景圖平鋪,同時設置背景色

安卓設置背景圖平鋪,同時設置背景色須要在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

相關文章
相關標籤/搜索