Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a custom progressbar in Android?

What would be the best way to make somthing looking like this:

enter image description here

The text on it needs to be customizable, not only numbers, some strings too, depending on context.

From what I see it:

  1. Create a custom View and within onDraw perform all the calculations and text alignment.
  2. Style or extend a horizontal ProgressBar.

What do you think ?

like image 948
Alin Avatar asked Jan 19 '12 15:01

Alin


People also ask

How can I customize my android progress bar?

Android App Development for Beginners This example demonstrates how to create a custom Progress Bar in Android using Kotlin. 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.

What is ProgressBar in android?

Android ProgressBar is a graphical view indicator that shows some progress. Android progress bar displays a bar representing the completing of the task. Progress bar in android is useful since it gives the user an idea of time to finish its task.

How do I make my progress bar horizontal android?

In Android, by default a progress bar will be displayed as a spinning wheel but If we want it to be displayed as a horizontal bar then we need to use style attribute as horizontal. It mainly use the “android. widget. ProgressBar” class.


1 Answers

Extend ProgressBar ... override onDraw()

The primary reason for this is that all of the primary methods are already there and the first rule of object-orientated programming is code-reuse means don't reinvent the wheel.

like image 85
Moog Avatar answered Nov 30 '22 17:11

Moog