Android全屏AlertDialog
我正在尝试在我的Android应用程序中进行全屏对话框,但我无法将其扩展到状态栏。您可以在下图中看到灰色状态栏。
编辑1: 这似乎是与已安装的操作系统相关的问题,而不是与Android组件相关的问题,因为我仅在某些设备上遇到此问题。
AlertDialog创建:
val builder = MaterialAlertDialogBuilder(this, R.style.FullscreenDialogStyle)
val binding = DialogSuccessBinding.inflate(layoutInflater)
binding.SuccessDialogMessage.text = getString(R.string.AddGuestCard_Success)
builder.setView(binding.root)
builder.background = ColorDrawable(getColor(R.color.primary))
builder.setBackgroundInsetBottom(0)
builder.setBackgroundInsetTop(0)
builder.setBackgroundInsetStart(0)
builder.setBackgroundInsetEnd(0)
builder.show()
AlertDialog样式:
<style name="FullscreenDialogStyle" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@color/primary</item>
<item name="android:navigationBarColor">@color/primary</item>
<item name="android:statusBarColor">@color/primary</item>
<item name="android:layout_gravity">center</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
</style>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以通过覆盖相机缺口区域(切割显示区域)使您的对话框全屏,您需要明确调整显示切口到
shortedges
始终使用Android:WindowLayOutIndisPlayCutOutMode
对话框主题中的属性:请在这里进行进一步研究;
To make your dialog a full screen by covering the camera notch area (cutout display area), you need to explicitly adjust the display cutout to
shortEdges
oralways
usingandroid:windowLayoutInDisplayCutoutMode
attribute in the dialog theme:Please check documentation here for further research;.
尝试以下操作:
try this: