Android: 如何在XML 中制作一个有一个角的圆形?

Android: How to make a circular shape with one corner in XML?

我需要在 xml 中为 android 项目描述以下形状。 我知道有圆角的 retangle,但我怎么能实现矩形只有一个角,其余的角是圆的?

这不会像人们在许多问题中询问的那样用作文本对话气泡。 我只想将形状用作一行文本的背景。 形状颜色应该很容易动态改变。

感谢您的帮助。

您可以将其添加到可绘制文件夹中的文件中:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<solid android:color="@android:color/holo_blue_dark" />
<corners
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="15dp"
    android:topLeftRadius="15dp"
    android:topRightRadius="15dp" /></shape>
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <solid android:color="#000"/>

    <corners android:bottomRightRadius="15dp"
             android:topLeftRadius="15dp"
             android:topRightRadius="15dp"/>
</shape>

只需在 drawable 文件夹中创建一个 xml 文件并将此 xml 设置为视图的背景。它应该像魅力一样工作。 如果您发现问题,请告诉我。

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
    android:topLeftRadius="20dp"
    android:topRightRadius="20dp"
    android:bottomLeftRadius="0dp"
    android:bottomRightRadius="20dp"
 /></shape>