Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Circle ProgressBar Android change Thickness etc

I am using the "normal" circle ProgressBar of Android which looks like this:

rogr

So, what I would like to do is to change the color, thickness and the corners (with cornerradius) of this ProgressBar.

I've found some examples for doing this stuff, but however it only was for horizontal ProgressBars, but I would like to keep this original ProgressBar.

Thank you very much!

like image 561
Tester Avatar asked Nov 05 '18 23:11

Tester


People also ask

How do I make a custom circular progress bar?

This example demonstrates how do I make circle custom progress bar in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.

How do I increase the size of my progress bar?

You try set Grid width=100 or bigger. And the ProgressRing should set HorizontalAlignment and verticalAlignment to Stretch and not any width,height and margin.

What is a difference between SeekBar and ProgressBar in android?

In Android, SeekBar is an extension of ProgressBar that adds a draggable thumb, a user can touch the thumb and drag left or right to set the value for current progress. SeekBar is one of the very useful user interface element in Android that allows the selection of integer values using a natural user interface.


1 Answers

A progress bar is essentially a rotate animation drawable. Here's something we use that is thinner with a different color gradient. You can see the use of thickness for width and start and end color.

Tweak to your liking:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="720" >

  <shape
      android:shape="ring"
      android:thickness="@dimen/progress_circle_thickness"
      android:useLevel="false" >

    <gradient
        android:angle="0"
        android:endColor="@color/progress_circle"
        android:startColor="@android:color/transparent"
        android:type="sweep"
        android:useLevel="false" />
  </shape>
</rotate>

and use in your layout something like this:

<ProgressBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:indeterminateDrawable="@drawable/progress_circle"/>
like image 115
Jeffrey Blattman Avatar answered Oct 12 '22 03:10

Jeffrey Blattman