本文主要是介绍Android Drawable Resources系列3:layer-list,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
定义:图层数组,根据先后顺序,越往后,图层越在顶部。
A LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.
FILE LOCATION:
res/drawable/filename.xml
The filename is used as the resource ID.
RESOURCE REFERENCE:
In Java: R.drawable.filename
In XML: @[package:]drawable/filename
SYNTAX:
<?xml version="1.0" encoding="utf-8"?>
<layer-listxmlns:android="http://schemas.android.com/apk/res/android" ><itemandroid:drawable="@[package:]drawable/drawable_resource"android:id="@[+][package:]id/resource_name"android:top="dimension"android:right="dimension"android:bottom="dimension"android:left="dimension" />
</layer-list>
参数名 | 作用 |
item | 可以直接使用drawable资源,也可以使用<bitmap>、<selector>标签的资源
|
top、right、bottom、left | 距离顶部、右边、底部、左边的距离。 |
效果示例:
资源:res\drawable\resource_drawable_layer_list.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:drawable="@drawable/resource_drawable_bitmap" /><item android:top="40dp" android:left="40dp"><bitmap android:src="@mipmap/reasource_drawable_mn" /></item><item android:top="80dp" android:left="80dp"><bitmap android:src="@mipmap/reasource_drawable_mn" /></item>
</layer-list>
使用:
<ImageViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_gravity="center"android:src="@drawable/resource_drawable_layer_list" />
效果:
这篇关于Android Drawable Resources系列3:layer-list的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!