Android笔记——用layer-list和shape画加号

首先layer-list可实现多个drawable叠加效果,每个drawable都写在item中以实现叠加,item是按从下往上顺序依次叠加。

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item>
        <rotate
            android:fromDegrees="135"
            android:visible="true">
            <shape android:shape="line">
                <stroke
                    android:width="1dp"
                    android:color="@color/black" />
            </shape>
        </rotate>

    </item>
    <item>
        <rotate
            android:fromDegrees="45"
            android:visible="true">
            <shape android:shape="line">
                <stroke
                    android:width="1dp"
                    android:color="@color/black"/>
            </shape>
        </rotate>
    </item>

</layer-list>

主要是用两个shape画直线,其中一条直线用rotate旋转90度变为横线,以此形成加号图像。
stroke的width表示直线的厚度。


加号
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。