通过 shape 实现梯形、三角形

通过 shape 实现梯形(可以用于右下角角标等)

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 梯形 -->
    <item>
        <rotate
            android:fromDegrees="45"
            android:pivotX="-45%"
            android:pivotY="85%">
            <shape android:shape="rectangle">
                <size
                    android:width="1dp"
                    android:height="8dp" />
                <solid android:color="#7d72ff" />
            </shape>
        </rotate>
    </item>
</layer-list>

通过 shape 实现梯形(可以用于左下角角标等)

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 左下角等腰梯形 -->
    <item>
        <rotate
            android:fromDegrees="45"
            android:pivotX="-45%"
            android:pivotY="85%">
            <shape android:shape="rectangle">
                <size
                    android:width="10dp"
                    android:height="2dp" />
                <solid android:color="#7d72ff" />
            </shape>
        </rotate>
    </item>
</layer-list>

通过 shape 实现正三角形(可以用于气泡上的三角等)  

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 正三角 -->
    <item>
        <rotate
            android:fromDegrees="45"
            android:pivotX="-45%"
            android:pivotY="85%">
            <shape android:shape="rectangle">
                <size
                    android:width="20dp"
                    android:height="21dp" />
                <solid android:color="#7d72ff" />
            </shape>
        </rotate>
    </item>
</layer-list>
发布了2 篇原创文章 · 获赞 1 · 访问量 1742

猜你喜欢

转载自blog.csdn.net/xueand/article/details/105687107