Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make ring shape with color slice android xml

Tags:

android

xml

I want to create a drawable like this for my progress bar

ring shape color slice

and I've tried this code, but I didnt get what I want

<?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>

This is what I've got

gradient

Is it possible to do this with only xml? Or this is should be done with java code?

like image 784
fadeltd Avatar asked Apr 12 '17 09:04

fadeltd


1 Answers

Since you asked in comments how do you do that and I can't put these links in a comment, I'll suggest you these three links. Read them and extract what you want:

how to draw a half circle in android

Draw a semicircle in the background of a View

https://github.com/devadvance/circularseekbar

like image 169
A. Badakhshan Avatar answered Oct 16 '22 14:10

A. Badakhshan