【问题标题】:How can I get negative radius Android Round Corner with XML如何使用 XML 获得负半径 Android Round Corner
【发布时间】:2021-10-21 03:36:22
【问题描述】:

我需要在 Android 中获得以下形状,因为使用约束布局无法获得此形状,请参阅我的代码。

    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/theme_dark"/>
            <corners android:topLeftRadius="0dp" android:topRightRadius="0dp"
                android:bottomLeftRadius="500dp" android:bottomRightRadius="0dp"/>
        </shape>
    </item>
</selector>

sample i need

【问题讨论】:

  • 考虑使用像PNG 这样的图像,或者更好的是SVG 图像来管理它

标签: android android-layout android-constraintlayout shapes


【解决方案1】:

试试这个可绘制的 xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/white"/>
        </shape>
    </item>
    <item
        android:bottom="0dp"
        android:left="-10dp"
        android:right="-200dp"
        android:top="-400dp">
        <shape android:shape="oval">
            <solid android:color="@color/purple_500"/>
        </shape>
    </item>
</layer-list>

以上drawable的输出是:

  • 如果将背景设置为屏幕的一半:

  • 如果将背景设置为全屏:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-27
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 1970-01-01
    • 1970-01-01
    • 2011-12-01
    相关资源
    最近更新 更多