Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want a progress circle instead of progress dialog

I want to show a progress Circle in my app while loading data. I have an activity and moving from one activity to another I am parsing some xml data so for the time being until the parsing is completed I want to show a circular loading effect.

like image 856
ta54 Avatar asked Mar 10 '11 12:03

ta54


People also ask

What can I use instead of progress dialog?

This class was deprecated in API level 26. ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar , which can be embedded in your app's UI.

How can I add progress bar in Android?

In android there is a class called ProgressDialog that allows you to create progress bar. In order to do this, you need to instantiate an object of this class. Its syntax is. ProgressDialog progress = new ProgressDialog(this);


2 Answers

You can use an indeterminate ProgressBar for the circular loading effect. Here is how you do it in XML:

<ProgressBar android:indeterminate="true"
            android:layout_width="50dp" android:layout_height="50dp"
            android:id="@+id/marker_progress" style="?android:attr/progressBarStyle"
            android:layout_gravity="center_vertical|center_horizontal"/>

You can change the height and width to be what you want. When you are done loading, you can change it's visibility to View.INVISIBLE or View.GONE

like image 121
Abhinav Avatar answered Oct 01 '22 17:10

Abhinav


You need to create animation xml file in res/anim folder and call startAnimation in your ImageView when you are loading data and stopAnimation when you stop loading data. And set loading image to ImageView, for example:

loading

This id code for circle animation xml file

<?xml version="1.0" encoding="UTF-8"?>
<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="infinite"
    android:duration="1200" 
    android:interpolator="@android:anim/linear_interpolator" />
like image 35
RomaTTi Avatar answered Oct 01 '22 18:10

RomaTTi