如何在android中创建自定义全屏ovarlay对话框
我需要创建一个自定义的全屏与叠加背景对话框。以下是预期结果的图像: 我尝试了下面的代码,但它没有显示像上面的图像如何在android中创建自定义全屏ovarlay对话框,android,kotlin,background,Android,Kotlin,Background,我需要创建一个自定义的全屏与叠加背景对话框。以下是预期结果的图像: 我尝试了下面的代码,但它没有显示像上面的图像 我的对话框打开对话框代码如下 这是我的dialogx.ml 它显示透明的背景。如何在图像上方创建对话框。请帮助我。Dialog Dialog=新建对话框(这是android.R.style.Theme\u Black\u NoTitleBar\u全屏); setContentView(R.layout.dialog); dialog.show() 您需要的是模糊效果,而不是半透明的
dialog.show() 您需要的是模糊效果,而不是半透明的黑色背景。也许这个答案可以帮助你:关于这个问题,有很多其他的答案,有不同的工作解决方案。
lateinit var dialog: Dialog
dialog = Dialog(this, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen)
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) // before
dialog.setContentView(R.layout.dialog)
dialog.setCancelable(true)
val lp = WindowManager.LayoutParams()
lp.copyFrom(dialog.getWindow()?.getAttributes())
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.height = WindowManager.LayoutParams.MATCH_PARENT
dialog.getWindow()!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
val d: Drawable = ColorDrawable(Color.BLACK)
d.setAlpha(130)
dialog.getWindow()!!.setBackgroundDrawable(d)
dialog.show()
dialog.getWindow()!!.setAttributes(lp)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#80000000"
android:orientation="vertical">
</LinearLayout>
**fill color #000000 with alph 50%**