自定义全屏行为
根据 android 文档,我们可以通过在 onCreate
方法中添加以下代码块(在 setContent{...}
内部,具体来说,如果您使用的是 Compose)
val windowInsetsController = ViewCompat.getWindowInsetsController(window.decorView)
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
但是,这似乎只隐藏了状态栏上显示的信息,仅用黑色条纹替换它。
现在,我的问题是 - 我们如何修改该条纹的颜色,以便应用程序的 UI 看起来延伸到整个显示屏?
我不知道从哪里开始,但我听说伴奏者可能有与此相关的东西,但我认为最好在这里发布这个问题,这样如果有人已经知道解决方法,他们可以分享,因为这将有助于社区。
除此之外,不涉及伴奏的解决方案也是受欢迎的,甚至可能是首选。
作为参考,这是现在的输出
注意到顶部的黑条了吗?这就是目标。
Per the android docs, we can make an activity go full-screen by adding the following block of code in the onCreate
method (inside setContent{...}
, specifically, if you are using Compose)
val windowInsetsController = ViewCompat.getWindowInsetsController(window.decorView)
windowInsetsController.systemBarsBehavior =
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
However, this seems to only hide the information displayed on the statusbar, replacing it with just a black stripe.
Now, my question is - How can we modify the color of this stripe so that the UI of the app seems to extend to the entire display?
I am not sure where to start but I've heard accompanist MAY have something related to this, but I thought it better to post this question here, so that if anyone already knows a way around, they may share since it will be helpful to the community.
Other than that, solutions that do not involve accompanist are also welcome, and may be even preferred.
For reference, here's the output as of now
Notice the black bar at the top? That's the target.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
复制并粘贴到 onCreate 方法中,结果你可以理解
copy and paste it in onCreate method after result you can understand