DialogFragment 设置内容xml布局中最外层背景色透明
之前试过在xml中直接设定background为透明色,但并未生效,还是默认为白色。
后来,我终于明白。
@Nullable
override fun onCreateView(inflater: LayoutInflater, @Nullable container: ViewGroup?, @Nullable savedInstanceState: Bundle?): View? {
mBinding = DataBindingUtil.inflate(inflater, R.layout.dialog_switch_account, container, false)
dialog.window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
return mBinding.root
}
是的,没错。就是这么一行: R.layout.dialog_switch_account, container, false)
dialog.window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
好了,我溜了溜了。