Development record of developer who study hard everyday.

, ,

[Solved] DialogFragment match_parent attribute is not working

 How to make DialogFragment match_parent

Android development blog



I used to make dialog using DialogFragment.

However, match_parent which is value of layout_width and layout_height attribute is not working.

With hard work and effort, I found the solution.

override fun onResume() {
super.onResume()

val params = dialog?.window?.attributes    //1
params?.width = ViewGroup.LayoutParams.MATCH_PARENT
params?.height = ViewGroup.LayoutParams.MATCH_PARENT
dialog?.window?.attributes = params as WindowManager.LayoutParams    //2
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))    //3
}

1 => Get window's attributes and set LayoutParams' value

2=> Set LayoutParams to window's attributes

3=> Make dialog's background transparent








Share:
Location: 대한민국 서울특별시

댓글 없음:

댓글 쓰기