如何用彩色片android xml制作戒指形状

fad*_*ltd 7 xml android

我想为我的进度条创建一个这样的drawable

环形彩色切片

我已经尝试过这段代码,但我没得到我想要的东西

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/progress">
        <shape
            android:innerRadiusRatio="3"
            android:shape="ring"
            android:useLevel="false">
            <gradient
                android:centerColor="#ffff00"
                android:endColor="#00ff00"
                android:startColor="#fb0000"
                android:type="sweep" />
        </shape>
    </item>
</layer-list>
Run Code Online (Sandbox Code Playgroud)

这就是我所拥有的

梯度

是否可以只用xml做到这一点?或者这应该用java代码完成?

A. *_*han 1

由于您在评论中询问如何做到这一点,并且我无法将这些链接放入评论中,因此我会建议您这三个链接。阅读它们并提取你想要的内容:

如何在android中画一个半圆

在View的背景中画一个半圆

https://github.com/devadvance/circularseekbar