有什么方法可以创建半圆作为形状吗?

mar*_*337 1 android android-drawable android-shape

我想为我的应用程序创建特殊视图。它是垂直的虚线和上下两个半圆。有什么方法可以将其创建为可绘制的单个形状吗?我做了虚线,但我不能做半圆。

它应该是这样的。

在此处输入图片说明

垂直虚线:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="90" android:toDegrees="90">
    <shape
            android:shape="line">
        <stroke
                android:color="#777777"
                android:dashWidth="7dp"
                android:dashGap="5dp"
                android:width="2dp"/>
    </shape>
</rotate>
Run Code Online (Sandbox Code Playgroud)

我发现有人试图做半圈,但它很大。我只需要小圆圈。它甚至不是圆圈。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners
            android:bottomLeftRadius="100000dp"
            android:topLeftRadius="0dp"
            android:bottomRightRadius="100000dp"
            android:topRightRadius="0dp" />

    <solid android:color="#777777" />
</shape>
Run Code Online (Sandbox Code Playgroud)

Mah*_*hil 6

half_circle.xmldrawable此行下创建文件

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

设置half_circle.xml为布局背景

输出将如下所示:

在此处输入图片说明