ProgressDialog is deprecated.What is the alternate one to use?

Yes, in API level 26 it’s deprecated. Instead, you can use progressBar. To create it programmatically: First get a reference to the root layout RelativeLayout layout = findViewById(R.id.display); //specify here Root layout Id or RelativeLayout layout = findViewById(this); Then add the progress bar progressBar = new ProgressBar(youractivity.this, null, android.R.attr.progressBarStyleLarge); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(100, 100); … Read more

How to change ProgressBar’s progress indicator color in Android

I copied this from one of my apps, so there’s prob a few extra attributes, but should give you the idea. This is from the layout that has the progress bar: <ProgressBar android:id=”@+id/ProgressBar” style=”?android:attr/progressBarStyleHorizontal” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:indeterminate=”false” android:maxHeight=”10dip” android:minHeight=”10dip” android:progress=”50″ android:progressDrawable=”@drawable/greenprogress” /> Then create a new drawable with something similar to the following (In this … Read more

How to display progress dialog before starting an activity in Android?

You should load data in an AsyncTask and update your interface when the data finishes loading. You could even start a new activity in your AsyncTask’s onPostExecute() method. More specifically, you will need a new class that extends AsyncTask: public class MyTask extends AsyncTask<Void, Void, Void> { public MyTask(ProgressDialog progress) { this.progress = progress; } … Read more

How to Create a circular progressbar in Android which rotates on it?

Here are my two solutions. Short answer: Instead of creating a layer-list, I separated it into two files. One for ProgressBar and one for its background. This is the ProgressDrawable file (@drawable folder): circular_progress_bar.xml <?xml version=”1.0″ encoding=”utf-8″?> <rotate xmlns:android=”http://schemas.android.com/apk/res/android” android:fromDegrees=”270″ android:toDegrees=”270″> <shape android:innerRadiusRatio=”2.5″ android:shape=”ring” android:thickness=”1dp” android:useLevel=”true”><!– this line fixes the issue for lollipop api 21 … Read more

How to create circular ProgressBar in android? [closed]

It’s easy to create this yourself In your layout include the following ProgressBar with a specific drawable (note you should get the width from dimensions instead). The max value is important here: <ProgressBar android:id=”@+id/progressBar” style=”?android:attr/progressBarStyleHorizontal” android:layout_width=”150dp” android:layout_height=”150dp” android:layout_alignParentBottom=”true” android:layout_centerHorizontal=”true” android:max=”500″ android:progress=”0″ android:progressDrawable=”@drawable/circular” /> Now create the drawable in your resources with the following shape. Play … Read more

How to Customize a Progress Bar In Android

Customizing a ProgressBar requires defining the attribute or properties for the background and progress of your progress bar. Create an XML file named customprogressbar.xml in your res->drawable folder: custom_progressbar.xml <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <!– Define the background properties like color etc –> <item android:id=”@android:id/background”> <shape> <gradient android:startColor=”#000001″ android:centerColor=”#0b131e” android:centerY=”1.0″ android:endColor=”#0d1522″ android:angle=”270″ /> </shape> </item> <!– Define the … Read more

How to change progress bar’s progress color in Android

For a horizontal ProgressBar, you can use a ColorFilter, too, like this: progressBar.getProgressDrawable().setColorFilter( Color.RED, android.graphics.PorterDuff.Mode.SRC_IN); Note: This modifies the appearance of all progress bars in your app. To only modify one specific progress bar, do this: Drawable progressDrawable = progressBar.getProgressDrawable().mutate(); progressDrawable.setColorFilter(Color.RED, android.graphics.PorterDuff.Mode.SRC_IN); progressBar.setProgressDrawable(progressDrawable); If progressBar is indeterminate then use getIndeterminateDrawable() instead of getProgressDrawable(). Since Lollipop … Read more