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.
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.
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);
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
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:
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With