1.介绍
(1)常识
(2)特点
2.实例演示
<1>新建drawable文件
app--->src---->main---->res---->drawable ,选中drawable文件夹,右击new--->drawable resource file
<2>xml文件代码
(1)layer1代码
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/grow"></item> <item android:id="@android:id/progress" android:drawable="@drawable/ok"></item> </layer-list>
(2)layer2代码
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <bitmap android:src="@drawable/img1" android:gravity="center"></bitmap> </item> <!--注意:第二个item与第一个item有一定的间距(左边14dp,上边14dp)--> <item android:left="14dp" android:top="14dp" > <bitmap android:src="@drawable/img2" android:gravity="center"></bitmap> </item> <item android:left="28dp" android:top="28dp" > <bitmap android:src="@drawable/img3" android:gravity="center"></bitmap> </item> </layer-list>
(3)主屏幕XML代码
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <SeekBar android:id="@+id/seekBar" android:progressDrawable="@drawable/layer1" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ImageView android:id="@+id/imageView" android:layout_width="188dp" android:layout_height="188dp" app:srcCompat="@drawable/layer2" /> </LinearLayout>