我正在尝试在 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>
最佳答案
yes, it has camera notch
要通过覆盖相机凹口区域(切口显示区域)使对话框全屏显示,您需要将显示切口显式调整为 shortEdges
或always
使用android:windowLayoutInDisplayCutoutMode
对话框主题中的属性:
<style name="FullscreenDialogStyle" parent="Theme.AppCompat.NoActionBar">
....
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
请check documentation此处进行进一步研究;.
关于Android 全屏警报对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72635367/