Create/Show custom Indeterminate progress bar in android programmatically

How to make progress bar like showing on application uninstall time time in android mobile phone.

Indeterminate progress bar is one of the most popular and usable progress bar and you can easily show its demo while un-installing any android application from your android device. This progress bar is a running progress bar with cutting edge effects. So here is the complete step by step tutorial for Create/Show custom Indeterminate progress bar in android programmatically.

android-project-download-code-button

How to Create/Show custom Indeterminate progress bar in android programmatically.

Code for MainActivity.java file.

 package com.indeterminateprogressbar_android_examples.com;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;

import android.widget.ProgressBar;

public class MainActivity extends Activity {

 ProgressBar bar;
 int value = 0;
 Handler handler = new Handler();
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 
 bar = (ProgressBar)findViewById(R.id.progressBar1);
 
 
 new Thread(new Runnable() {
 @Override
 public void run() {
 while(value < 100){
 value ++;

 try{
 Thread.sleep(20);
 }catch(InterruptedException e){
 e.printStackTrace();
 }

 handler.post(new Runnable() {
 @Override
 public void run() {
 
 bar.setProgress(value);
 
 }
 });
 }
 }
 }).start();
 }
 
}

Code for activity_main.xml layout file.

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.indeterminateprogressbar_android_examples.com.MainActivity" >

 <ProgressBar
 android:id="@+id/progressBar1"
 style="@android:style/Widget.ProgressBar.Horizontal"
 android:layout_width="230dp"
 android:layout_height="wrap_content"
 android:layout_centerHorizontal="true"
 android:layout_centerVertical="true"
 android:indeterminate="true" />

</RelativeLayout>

Screenshot:

Create/Show custom Indeterminate progress bar in android programmatically

Click here to download Create/Show custom Indeterminate progress bar in android programmatically project with source code.