Skip to content Skip to sidebar Skip to footer

Change Style Of Progressdialog

Is it possible to change ProgressBar style of progress dialog. If yes, then how can I do it?

Solution 1:

You can style your progress dialog this way: create a drawable file with your ring shape (circular_progress_dialog.xml)

<rotatexmlns:android="http://schemas.android.com/apk/res/android"android:fromDegrees="270"android:toDegrees="270"><shapeandroid:innerRadiusRatio="2.5"android:shape="ring"android:thickness="2dp"android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 --><gradientandroid:angle="0"android:endColor="@color/main_background"android:startColor="@color/main_orange"android:type="sweep"android:useLevel="false" /></shape></rotate>

one to style your progress bar

<stylename="ProgressBar"parent="@android:style/Widget.ProgressBar"><itemname="android:layout_centerHorizontal">true</item><itemname="android:layout_centerVertical">true</item><itemname="android:visibility">gone</item><itemname="android:background">@color/transparency_pleca</item><itemname="android:indeterminateDrawable">@drawable/circular_progress_dialog</item></style>

Notice your "android:indeterminateDrawable" property

Yout can create an instance of ProgressDialog and add your style with

// create progressDialogfinalProgressDialogmyProgressDialog=newProgressDialog(MyActivity.this);
myProgressDialog.setProgressStyle(R.style.ProgressBar)
myProgressDialog.show();

Post a Comment for "Change Style Of Progressdialog"