android dialog 全屏探究

 在使用 bottomsheetdialog 的时候发现   dialog 是全屏的 一直然后想稍微深入下 解决 一下一直以来的dialog 全屏问题

 发现 1. bottomsheetdialog  源码中 没使用 主题的时候 默认使用

  主题 : Theme.Design.BottomSheetDialog

      然后 在oncreate 中使用 getwindow.setlayout(mathparent,matchparent) 

就可以使 dialog 全屏  (ps  : window 设置属性需要 在setcontentview 之后 才能生效)

2.继续 向上找源码 发现 这个  style 继承 于 Base.Theme.AppCompat

  这个 style  其中 也设置了 window 的背景样式 :@drawable/abc_dialog_material_background

里面的内容是  :  带边距 的  所以 当我们 给window 重新设置的时候 ,我们的window 就可以全屏显示了

《android dialog 全屏探究》

    原文作者:zlzxm
    原文地址: https://www.jianshu.com/p/2ab9d6ae863a
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞