Theme not applying to DialogFragment on Android

后端 未结 5 1851
孤独总比滥情好
孤独总比滥情好 2020-12-13 23:59

I\'m switching my old Dialogs to DialogFragment, but the themes and styles don\'t seem to be working.

I\'m using the DialogFragment from the compatibility library v

5条回答
  •  感动是毒
    2020-12-14 00:10

    You shoudn't use the AlertDialog.Builder(Context, int) constructor with the support library because it is only available since API 11.

    To setup a theme to your dialog, use instead a ContextThemeWrapper like this:

    ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Dialog_NoActionBar);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    

提交回复
热议问题