How to set the width of a DialogFragment in percentage?

后端 未结 2 2164
[愿得一人]
[愿得一人] 2021-02-15 01:19

I have a DialogFragment with an xml layout and I need it to be, let\'s say 75% as wide as the screen. When I look for answers I always find the common weight<

2条回答
  •  遥遥无期
    2021-02-15 01:55

    You can achieve this by setting a style to your dialogfragment on it's onCreate method:

    setStyle(DialogFragment.STYLE_NORMAL,R.style.yourStyle);
    

    and in your styles.xml

       
    

提交回复
热议问题