我正在尝试创建一个用于 Android 项目中的图像按钮的形状,该形状基本上在左侧和右侧都有半圆。
我想我可以只使用带有半径的形状 XML,但这只是圆角,我需要整个左侧和右侧是半圆,如下图所示。
我当前的形状 XML 如下所示:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:color="@color/white">
<corners
android:radius="60dip"
/>
<stroke
android:width="0dp"
android:color="#000000" />
<solid
android:color="@color/white" />
</shape>
but I am trying to get this effect :
您必须像这样指定每个角半径:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/green" />
<size android:height="30dp" />
<corners
android:bottomRightRadius="15dp"
android:bottomLeftRadius="15dp"
android:topRightRadius="15dp"
android:topLeftRadius="15dp"
/>
</shape>
您不应该指定宽度,以便它可以将宽度调整为背景可绘制。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)