Reputation: 2576
How can I set a theme for all progress bars that I create in my Project ?
This is my style :
<style name="MyTheme.ProgressDialog" parent="android:Theme.Holo.Light.Dialog.NoActionBar">
<item name="android:textColor">@android:color/anyColor</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
And I set it manually in the constructor of each progressDialog I create :
loadingDialog = new ProgressDialog(this, R.style.MyTheme_ProgressDialog);
Can I set the theme to be the default for all progress dialogs I create without changin it in the constructor each time ?
Upvotes: 1
Views: 4619
Reputation: 2075
ProgressDialog
has only one more constructor ProgressDialog(Context) which internaly use com.android.internal.R.style.Theme_Dialog_Alert
style. There is no way you can override it. By contrast you can create a simple subclass of ProgressDialog and create a constructor with it which will use your style. That way you will not have to specify style every time.
public class MyProgressDialog extends ProgressDialog {
public MyProgressDialog(Context context) {
super(context, R.style.your_custom_style);
}
public MyProgressDialog(Context context, int theme) {
super(context, theme);
}
}
Upvotes: 3
Reputation: 189
set in style.xml your progress style like this:
<style name="progressBar" parent="android:Widget.Holo.ProgressBar.Large">
<item name="android:progressBarStyle">@android:style/Widget.Holo.Light.ProgressBar.Large</item>
</style>
then in all progressbars set style attribute as follow:
<ProgressBar
android:id="@+id/loading_spinner_1"
style="@style/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" />
Upvotes: 0