How to change theme for AlertDialog

前端 未结 15 2111
名媛妹妹
名媛妹妹 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:32

    I"m not sure how Arve's solution would work in a custom Dialog with builder where the view is inflated via a LayoutInflator.

    The solution should be to insert the the ContextThemeWrapper in the inflator through cloneInContext():

    View sensorView = LayoutInflater.from(context).cloneInContext(
         new ContextThemeWrapper(context, R.style.AppTheme_DialogLight)
    ).inflate(R.layout.dialog_fingerprint, null);
    

提交回复
热议问题