【问题标题】:How do I create a bottom cut half oval shaped button in Android?如何在 Android 中创建一个底部切割的半椭圆形按钮?
【发布时间】:2021-05-16 21:49:00
【问题描述】:

我正在尝试创建一个半椭圆形按钮,这在模型中很容易,但我发现在 XML 文件中很难做到。此外,我希望涟漪效应仅限于椭圆形。 可能有一种方法可以在我不知道的形状 XML 文件中切割一个椭圆。

我想要达到的目标:

但我得到的最接近的是:

使用以下代码:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#8C9AEE"/>
    <size
        android:width="120dp"
        android:height="60dp"/>
    <corners
        android:topLeftRadius="140dp"
        android:topRightRadius="140dp"/>
</shape>

任何建议将不胜感激。我看到的所有选项都没有达到预期的效果。

【问题讨论】:

    标签: android xml button shapes


    【解决方案1】:

    试试下面的代码

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="oval">
        <solid android:color="#8C9AEE" />
        <size
            android:width="120dp"
            android:height="60dp" />
    
    </shape>
    

    查看以下资源

    Half circle shape not work

    希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 2022-10-14
      • 2017-12-18
      • 2017-03-04
      • 2016-12-22
      相关资源
      最近更新 更多