Custom progress bar with custom levels

I want to create a custom progress bar with various levels, for example below:

enter image description here

xml code;

 <ProgressBar
    android:id="@+id/progress"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="300dp"
    android:layout_height="300dp"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="20dp"
    android:indeterminate="true"
    android:indeterminateDrawable="@drawable/progress"  />

progrss.xml;

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >

<shape
    android:innerRadiusRatio="3"
    android:shape="ring"
    android:thicknessRatio="10"
    android:useLevel="false" >

    <size
        android:height="76dip"
        android:width="76dip" />

    <gradient
        android:angle="0"
        android:endColor="#99cc33"
        android:startColor="#F15d36"
        android:type="sweep"
        android:useLevel="false" />

</shape>

</rotate>
+4
source share
2 answers

you can use custom progress bar for your requirement

CircularProgressView

https://android-arsenal.com/details/1/6152

0
source

You need a custom layout like -

class CircleLayout extends FrameLayout{
...
  void onDraw(Canvas canvas){
  .... 
  }
}

Now in the onDraw () method, draw a circle with a radius equal to half min (height, width) -
height and width - height and width of Framelayout, respectively,
sayint min= min(height,widht)

radius = min/2

x and y are the center point

canvas.drawCircle(x, y, radius, paint);

, , greenArc redArc
- http://android-coding.blogspot.in/2012/04/draw-arc-on-canvas-canvasdrawarc.html

0

Source: https://habr.com/ru/post/1694636/


All Articles