dialog
设置主题样式
<style name="pro_dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item><!--边框-->
<item name="android:windowIsFloating">true</item><!--是否浮现在activity之上-->
<item name="android:windowIsTranslucent">true</item><!--半透明-->
<item name="android:windowNoTitle">true</item><!--无标题-->
<item name="android:windowBackground">@color/transparent</item><!--背景透明-->
<item name="android:backgroundDimEnabled">false</item><!--模糊-->
</style>
dialogFragment
代码设置
//设置内部背景透明
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
//建议在onStart设置
override fun onStart() {
super.onStart()
//设置外部背景透明
val lp: WindowManager.LayoutParams = dialog?.window?.attributes!!
lp.dimAmount = 0f
lp.width = LinearLayout.LayoutParams.WRAP_CONTENT
lp.height = LinearLayout.LayoutParams.WRAP_CONTENT
dialog?.window?.attributes = lp
}