我制作了一个可绘制的按钮,它由渐变形状和实体形状组成,两者都在这样的图层列表中:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:height="25dp">
<shape android:shape="rectangle" >
<gradient
android:angle="90"
android:startColor="@color/greyDark1"
android:endColor="@color/greyDark2"/>
</shape>
</item>
<item android:top="25dp" android:height="25dp">
<shape android:shape="rectangle" >
<solid android:color="@color/black" />
</shape>
</item>
</layer-list>
但是我无法正确理解角落.我需要在整个形状周围的圆角,但不是在内侧(所以topRight和topLeft op的上半部分和bottomRight和bottomLeft的下半部分).
如果我用< corner android:radius =“8dp”>设置两半.上半部分的底角和下半部分的顶角也是圆形的,这不是我想要的.
如果我设置< corner android:topRightRadius =“8dp”android:topLeftRadius“8dp”>对于上半部分和< corner android:bottomRightRadius =“8dp”android:bottomLeftRadius“8dp”>对于下半部分,上半部分将是可绘制的全尺寸,使得渐变不能正常工作,底角也是相同的颜色.
这是我想要完成的图像:
有人知道解决方案吗?
编辑:
我得到了一些答案,我很感激,但遗憾的是它们似乎没有用.
我从bofredo和Bhuvnesh Chasta得到的答案产生了这样的结果:
我从curiousMind得到的答案看起来很不错,但不是我的目标:
最终编辑:
我和我一起工作的人讨论过这个问题,我们都同意让它看起来像这样并不重要,所以我们选择了纯色.
我仍然要感谢所有帮助过的人,所有目前的答案都会得到一个赞成,我会接受waqaslam的回答,因为他非常接近我想要的.