">
美文网首页我爱编程
android layer-list 简单介绍

android layer-list 简单介绍

作者: XX杰 | 来源:发表于2018-05-25 14:21 被阅读0次

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

<!--
 **  每一个item 代表一层。
 **  后一个item的大小和形状都是在前一个item的基础上进行另一层的变化。
 **  第一层 我定义了形状和颜色,还有大小
 **  第二层 我定义了一个白色的背景但是被旋转了-45度,在经过平移得到一条斜边
 **  第三层也是同样的道理
 -->

<item>
    <shape android:shape="rectangle">
        <size android:height="@dimen/member_postion_button_height"
            android:width="@dimen/member_postion_button_width"/>
        <solid android:color="@color/member_postion_nofocus_color" />
    </shape>
</item>

<!--
**  item 中的属性 left right top bottom 是行对于当前位置进行平移调整
**  例如: 当前的高度是 member_postion_button_height
**  android:bottom = 10dp  的效果是相当于当前的地步位置上移10dp,
**  因为总的高度是固定的,上移之后,会有10dp不在高度范围里面,所以效果就是高度从下面减少了10dp
**  如果是-10dp的话,就拉长了10dp, 是在原来的高度上向下拉长了10dp
**  所以通过正负值可以实现平移的效果
-->

<item
    android:right="@dimen/member_postion_button_width"
    android:left="@dimen/member_postion_button_fuwidth"
    android:top="@dimen/member_postion_button_fuwidth"
    android:bottom="@dimen/member_postion_button_fuwidth" >
    <rotate android:fromDegrees="45">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </rotate>
</item>

<item
    android:right="@dimen/member_postion_button_fuwidth"
    android:left="@dimen/member_postion_button_width"
    android:top="@dimen/member_postion_button_fuwidth"
    android:bottom="@dimen/member_postion_button_fuwidth">
    <rotate android:fromDegrees="45">
        <shape android:shape="rectangle">
            <solid android:color="#ffffff" />
        </shape>
    </rotate>
</item>
</layer-list>

相关文章

网友评论

    本文标题:android layer-list 简单介绍

    本文链接:https://www.haomeiwen.com/subject/hyzyjftx.html