14

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

Aram
  • 695
  • 1
  • 5
  • 20
  • what kind of style do you want....??? – Dinesh Sharma Jan 31 '12 at 09:22
  • Quite easy to do this and the code can be found at the – akkilis Jan 31 '12 at 09:23
  • Thank you for your quick replies, I just want to change default ProgressBar animation with my custom animation. – Aram Jan 31 '12 at 09:27
  • possible duplicate of [custom Progress Dialog in android?](http://stackoverflow.com/questions/2571361/custom-progress-dialog-in-android) – Oliver Jan 31 '12 at 09:58
  • http://stackoverflow.com/questions/16909958/how-to-set-theme-to-progressdialog My Answer: http://stackoverflow.com/a/21795203/1314977 – JeffMeJones Feb 15 '14 at 08:43
  • You should try Googling whatever it is that you are asking about before posting here. See these Google results: [1.Custom Progress Dialog](http://stackoverflow.com/questions/2571361/custom-progress-dialog-in-android) [2. Custom Style Progress Dialog](http://stackoverflow.com/questions/2819778/custom-drawable-for-progressbar-progressdialog) [3. Custom Progress Dialog using Custom Layout](http://www.anddev.org/view-layout-resource-problems-f27/how-use-a-custom-layout-for-a-progressdialog-t9754.html) [4. Creating Custom Skinny Progress Bar](http://sherifandroid.blogspot.in/2011/08/creating-skinny – Praveenkumar Jan 31 '12 at 09:33

1 Answers1

5

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

<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="2dp"
    android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->

    <gradient
        android: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

 <style name="ProgressBar" parent="@android:style/Widget.ProgressBar">
    <item name="android:layout_centerHorizontal">true</item>
    <item name="android:layout_centerVertical">true</item>
    <item name="android:visibility">gone</item>
    <item name="android:background">@color/transparency_pleca</item>
    <item name="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 progressDialog
final ProgressDialog myProgressDialog = new  ProgressDialog(MyActivity.this);
myProgressDialog.setProgressStyle(R.style.ProgressBar)
myProgressDialog.show();
OnesimusUnbound
  • 2,886
  • 3
  • 30
  • 40
AlbertoRuvel
  • 356
  • 4
  • 14