Thursday, August 17, 2017

How Progress bar in Android

Hello,
        In this tutorial I will show you how to show Progress bar in your Android App, so that while performing a time consuming task such as fetching data from a URL, you can show progress Dialog.

In Order to show a Progress bar follow these steps

1. Add Progress bar in your XML Layout  

 <ProgressBar  
       android:id="@+id/toolbarProgressBar"  
       style="?android:attr/progressBarStyleLarge"  
       android:layout_width="match_parent"  
       android:layout_height="wrap_content"  
       android:layout_centerHorizontal="true"  
       android:layout_centerVertical="true"  
       android:visibility="gone" />  

2. Now to show the progress bar

  progressBar=(ProgressBar) findViewById(R.id.toolbarProgressBar);  
       progressBar.setVisibility(View.VISIBLE);  
       progressBar.animate();  


3. To Stop the Progress bar

  progressBar.setVisibility(View.GONE);  


I hope it was informative for you, and I would like to Thank you for reading.