美文网首页
Android笔记——用layer-list和shape画加号

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

作者: 麦香菌 | 来源:发表于2020-06-06 12:06 被阅读0次

首先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表示直线的厚度。


加号

相关文章

网友评论

      本文标题:Android笔记——用layer-list和shape画加号

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