How to change theme for AlertDialog

前端 未结 15 2124
名媛妹妹
名媛妹妹 2020-11-22 09:14

I was wondering if someone could help me out. I am trying to create a custom AlertDialog. In order to do this, I added the following line of code in styles.xml



        
15条回答
  •  借酒劲吻你
    2020-11-22 09:45

    For Custom Dialog:

    just call super(context,R.style.

    ) instead of super(context) in dialog constructor

    public class MyDialog extends Dialog
    {
        public MyDialog(Context context)
        {
           super(context, R.style.Theme_AppCompat_Light_Dialog_Alert)
        }
    }
    


    For AlertDialog:

    Just create alertDialog with this constructor:

     new AlertDialog.Builder(
     new ContextThemeWrapper(context, android.R.style.Theme_Dialog))
    

提交回复
热议问题