如何使无半径的底角?

时间:2016-11-04 23:40:01

标签: android xml android-studio

我想制作一个只有圆角的顶角。

这是我现在的XML:

<corners
        android:topLeftRadius="6dp"
        android:topRightRadius="6dp"
        android:bottomLeftRadius="0dp"
        android:bottomRightRadius="0dp" />

但它没有按预期工作(底角保持四舍五入)。 如何只用顶角四舍五入来制作XML?

1 个答案:

答案 0 :(得分:0)

如果您只想创建一个圆角按钮,那么您可以这样做,如果您想要更改,则只需更改角半径即可。这在设计时无法正常显示,但是当你运行时,它的工作正常。我希望这会对你有所帮助。
这是左上角和右上角是圆形的,左下角是不圆的。 的 top_left_right_corner_rounded.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" android:padding="10dp">

    <solid android:color="@color/colorPrimary"/>

    <corners
        android:radius="3dp"
        android:bottomRightRadius="0dp"
        android:bottomLeftRadius="0dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp"/>
</shape>