【问题标题】:NoSuchMethodError setDecorFitsSystemWindows when I use window?.setDecorFitsSystemWindows(true)NoSuchMethodError setDecorFitsSystemWindows 当我使用 window?.setDecorFitsSystemWindows(true)
【发布时间】:2021-09-30 06:15:58
【问题描述】:

我想让我的 Activity 出现在屏幕上,并且 StatusBar 透明,所以我写了这段代码:

window?.setDecorFitsSystemWindows(true)
window?.statusBarColor = Color.TRANSPARENT

我的 targetVersion 是 30 我的 appcompat 版本是 1.3.0

但是当我运行它时,我得到了这样的异常 enter image description here

【问题讨论】:

  • 试试这个WindowCompat.setDecorFitsSystemWindows(window, true)...另外请将完整的堆栈跟踪添加为文本而不是图像。
  • 谢谢,它有效,也谢谢你的建议

标签: android statusbar android-statusbar android-window


【解决方案1】:

因此,要删除此异常,您需要使用兼容版本的窗口(即WindowCompat

所以替换:

window?.setDecorFitsSystemWindows(true)

与:

WindowCompat.setDecorFitsSystemWindows(window, true)

【讨论】:

    猜你喜欢
    • 2022-08-17
    • 1970-01-01
    • 2022-12-03
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 2014-09-04
    • 1970-01-01
    • 2021-10-20
    相关资源
    最近更新 更多