<layer-list> :图层列表
最简单的效果
简单的使用:res/drawable/xxx.xml 下,将<layer-list>作为根元素,XML命名空间必须是"http://schemas.android.com/apk/res/android"
<item>作为其子对象,分别绘制不同的对象。
android:width 宽度
android:height 高度
android:top
顶部偏移(相对手机的上下左右)
android:right
右边偏移(同上)
android:bottom
底部偏移(同上)
android:left
左边偏移(同上)
xxx.xml文件将当做图片一样在可以被引用
代码:
xxx.xml :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/colorAccent"
android:width="80dp"
android:height="80dp"></item>
<item android:drawable="@color/colorPrimary"
android:width="80dp"
android:height="80dp"
android:top="30dp"
android:left="30dp">
</item>
</layer-list>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/xxx"/>