當我們需要把多個圖層疊在一起顯示時,可以使用 layer-list。
首先在 /res/drawable/ 資料夾下建立 test.xml,內容如下:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:Android="https://schemas.android.com/apk/res/android">
<item>
<shape>
<solid android:color="#FFB2B9BE" />
</shape>
</item>
<item android:bottom="1px">
<shape>
<gradient android:startColor="#FFDCE2E6"
android:endColor="#FFBAC2C6"
android:angle="-90" />
</shape>
</item>
</layer-list>使用時與其他資源檔用法相同,透過 android:background="@drawable/test" 即可套用。