如何在android中制作圆弧

5 xml android

我只想知道怎么做这个半圆

在此处输入图片说明

但我的输出是这样的

在此处输入图片说明

这是我的 xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:topLeftRadius="20dp"
android:topRightRadius="20dp"
 />
<stroke
    android:width="2dip"
    android:color="@android:color/darker_gray"
    />
<padding
    android:left="4dp"
    android:right="4dp"
     />
Run Code Online (Sandbox Code Playgroud)

Fro*_*and 3

试试这个代码:

 <?xml version="1.0" encoding="utf-8"?>
    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <solid android:color="#900021df"/>
        <size
        android:width="120dp"
        android:height="60dp"/>
       <corners
        android:topLeftRadius="60dp"
        android:topRightRadius="60dp"/>
    </shape>
Run Code Online (Sandbox Code Playgroud)

在drawable文件夹下创建一个semicircle.xml。
将以上代码添加到您的 XML 中。
请让我知道它是否有效...

输出看起来像

在此输入图像描述

编辑:

只需对上面的代码稍加改动即可。

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

   <size
       android:width="120dp"
       android:height="60dp"/>
   <corners
       android:topLeftRadius="60dp"
       android:topRightRadius="60dp"/>
   <stroke
      android:color="#919191"
      android:width="1dp"
      />

</shape>
Run Code Online (Sandbox Code Playgroud)


输出:
在此输入图像描述

不满意?为什么不使用它在画布上创建它使用它将SVG 转换为 XML 代码?