我正在尝试创建一个半椭圆形状的按钮,这在样机中很容易,但我发现在XML文件中做这件事相当困难。另外,我希望涟漪效果仅限于椭圆形。可能有一种方法可以在shape 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>
任何建议都将不胜感激。我看到的选项都没有达到预期的结果。
发布于 2021-05-17 00:50:47
尝试以下代码
<?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>
或
请参阅以下资源
希望你能帮上忙!
https://stackoverflow.com/questions/67561844
复制