How to hide ActionBar with Jetpack Compose(如何使用Jetpack Compose隐藏ActionBar)
本文介绍了如何使用Jetpack Compose隐藏ActionBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想隐藏默认操作栏,因此在清单文件中有以下代码:
<style name="Theme.MyCompose" parent="Theme.Material.DayNight.NoActionBar">
</style>
<style name="Theme.Material.DayNight.NoActionBar" parent="@android:style/Theme.Material.Light.NoActionBar" />
效果如下:
我想实现的目标如下:
摄影应覆盖白色区域。如何做到这一点?
更新%1
在实施了半透明状态栏和伴奏插入支持的解决方案后,我遇到了奇怪的行为。当窗口标志设置如下:
window.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
所有内容看起来都是这样的,尽管插图是打开的:
删除这些标志时,insets起作用,但我有那个影子:
推荐答案
如果需要完全隐藏状态栏,则需要使用全屏主题,如this answer
所示如果您需要一个透明的状态栏,您可以按照this answer,外加设置Accompanist Insets进行如下操作:
WindowCompat.setDecorFitsSystemWindows(window, false)
window.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
然后,您可以在合成中使用systemBarsPadding
和其他Accompanist Insets修饰符将图像设置为背景并偏离状态/导航栏。
setContent {
ProvideWindowInsets {
ComposePlaygroundTheme {
Box {
Image(
painterResource(id = R.drawable.my_image),
contentDescription = "...",
contentScale = ContentScale.FillBounds,
modifier = Modifier.fillMaxSize()
)
Column(
Modifier.systemBarsPadding()
) {
Button(onClick = { /*TODO*/ }) {
Text("Hello")
}
}
}
}
}
}
结果:
这篇关于如何使用Jetpack Compose隐藏ActionBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:如何使用Jetpack Compose隐藏ActionBar


猜你喜欢
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01