Below is my code for custom progress bar. I have issue with just Gravity.
Here is the code.
dialog = new ProgressDialog(LandingPageActivity.this, R.style.AppBaseTheme);
dialog.setCancelable(false);
dialog.setIndeterminateDrawable(getResources().getDrawable(R.anim.progressbar));
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.getWindow().setGravity(Gravity.CENTER_HORIZONTAL);
dialog.show();
Style.xml
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<item name="android:alertDialogStyle">@style/CustomAlertDialogStyle</item>
<item name="android:windowBackground">@color/transparent</item>
</style>
style name="CustomAlertDialogStyle">
<item name="android:bottomBright">@color/transparent</item>
<item name="android:bottomDark">@color/transparent</item>
<item name="android:bottomMedium">@color/transparent</item>
<item name="android:centerBright">@color/transparent</item>
<item name="android:centerDark">@color/transparent</item>
<item name="android:centerMedium">@color/transparent</item>
<item name="android:fullBright">@color/transparent</item>
<item name="android:fullDark">@color/transparent</item>
<item name="android:topBright">@color/transparent</item>
<item name="android:topDark">@color/transparent</item>
<item name="android:gravity">center</item>
</style>
animation file code
<animation-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/anim00" android:duration="150" />
<item android:drawable="@drawable/anim01" android:duration="150" />
<item android:drawable="@drawable/anim02" android:duration="150" />
<item android:drawable="@drawable/anim04" android:duration="150" />
</animation-list>
I am able to show progress bar correctly but gravity is taking Left Top by default.
Appreciate your help.
Thanks
Solution:
You need to make one custom style in
style.xml
file which has aandroid:Theme.Holo.Dialog
theme. Like,CustomProgress
and add your
CustomAlertDialogStyle
to yourCustomProgress
style instead ofAppBaseTheme
.Now use your custom style for your
ProgressDialog