Skip to content

Note when custom dialog themes

Logan Guo edited this page Jan 2, 2016 · 2 revisions

Note when custom themes for dialogs

  1. Beware of the theme and style when apply theme attribute. this is correct <item name="android:alertDialogTheme">@style/DialogTheme</item>
  2. Distinct and support at least two themes for pre-L and post-L devices
  3. If you want to apply to your AlertDialog a theme different than the one specified in your Activity’s theme, you can use a ContextThemeWrapper around your current context:
ContextThemeWrapper ctw = new ContextThemeWrapper(this, R.style.DialogTheme);
        final AlertDialog.Builder builder = new AlertDialog.Builder(ctw);