简体   繁体   中英

Custom Alert Style with Multiple Theme

I am confused while using custom alert dialogue styles in my application, due to there being multiple themes in my application. I have three themes in my application, called themeGrey, themeTeal and themePink. I have an alert dialogue style like below

style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">

        <item name="android:textColorPrimary">@color/colorAccent</item>
        <item name="android:textColor">@color/colorAccent</item>
        <item name="android:background">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="textColorAlertDialogListItem">@color/colorAccent</item>
        <item name="android:textColorSecondary">@color/colorAccent</item>

    </style>

I have used it in my app like below

mProgress = new ProgressDialog((this), R.style.AlertDialogTheme);

Now my question is, how can I define a different style for each theme? I do not want apply with a conditional. Can I do it by declaring a theme as an item? Thanks

I have solved removing style from java code like below

mProgress = new ProgressDialog((this));

and delcared alert style in theme like below

<item name="android:alertDialogTheme">@style/AlertDialogThemeTeal</item>

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM