4

我试图为我的活动提供一个我希望被低估的一般背景,所以我决定在一个角落使用少量紫色,在另一个角落使用少量绿色,并带有非常大的白色带它们之间。

我看不到如何设置中心颜色宽度,因此尝试使用图层列表达到以下效果:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="0dp" android:left="0dp" android:bottom="0dp" android:right="0dp">
    <shape android:shape="rectangle">
        <size android:width="20dp"
            android:height="20dp"/>
        <solid android:color="#00000000"/>
    </shape>
</item>

<item android:top="0dp" android:left="0dp" android:bottom="15dp" android:right="15dp">
    <shape android:shape="rectangle">
        <size android:width="1dp"
            android:height="1dp"/>
        <gradient
            android:startColor="#00000000"
            android:centerColor="#00000000"
            android:endColor="#92ff16"
            android:angle="135"/>
    </shape>
</item>

<item android:top="15dp" android:left="15dp" android:bottom="0dp" android:right="0dp">
    <shape android:shape="rectangle">
        <size android:width="1dp"
            android:height="1dp"/>
        <gradient
            android:startColor="#ff1692"
            android:centerColor="#00000000"
            android:endColor="#00000000"
            android:angle="135"/>
    </shape>
</item>
</layer-list>

这在 Android Studio 设计器中看起来不错,但在应用程序中,彩色方块重叠,即使它们的 dp 数字非常小。

有没有一种简单的方法来分隔角落的形状?

4

0 回答 0