简体   繁体   English

android 中约束布局的透明背景不起作用

[英]Transparent background for constraint layout in android not working

Transparent background for constraint layout in android not working android 中约束布局的透明背景不起作用

I'm trying to make a custom android dialog with rounded corners.我正在尝试制作一个带有圆角的自定义 android 对话框。 enter image description here在此处输入图像描述

As you can see, the corners are rounded, but it leaves the white corner still intact.如您所见,边角是圆形的,但白色边角仍然完好无损。

If you using Fragment that extends with DialogFragment()如果您使用通过DialogFragment()扩展的片段

 override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    requireDialog().window?.setBackgroundDrawableResource(R.drawable.white_curve_with_blue_outline)//you can use here the drawable
    requireDialog().window?.setBackgroundDrawable(ColorDrawable(Color.parseColor("#BF303030")))//you can use here the color/Transparent


}

Try this in your dialogue activity在你的对话活动中试试这个

yourDialogName.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM