Resource之layer-list(LayerDrawable)

来源:互联网 发布:滴滴查评星软件下载 编辑:程序博客网 时间:2024/05/16 17:26
一 LayerDrawable
      LayerDrawable包含一个drawable数组,android系统按照顺序去绘制它们,在XML自定义要使用<layer-list>...</layer-list>元素。
其属性有:
android:drawable :指定drawable对象;
android:id : 为drawable指定唯一标识;
android:bottom|top|left|right:指定在目标控件绘制的位置。
二 示例
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@mipmap/pic_3">
</item>
<item
android:top="50dp"
android:left="50dp"
android:drawable="@mipmap/pic_2"
android:gravity="center">
</item>
<item
android:top="100dp"
android:left="100dp"
android:drawable="@mipmap/pic_1"
android:gravity="center">
</item>
</layer-list>
XML布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:src="@drawable/res_layer_drawable"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
效果图:






















原创粉丝点击