【问题标题】:Bottom nav not alligning to bottom底部导航未与底部对齐
【发布时间】:2020-12-28 05:04:28
【问题描述】:

我已经成功创建了一个bottomNavigation,但是当我执行我的代码时它似乎在顶部而不是在屏幕底部,我需要做其他事情吗?

@Composable
fun BottomNavWithLabels(){
    BottomNavigation(content = {
        listItems.forEachIndexed { index, label ->
            BottomNavigationItem(
                    icon = {
                                Icon(vectorResource(id = R.drawable.ic_baseline_home_24))
                          
            )
        }
    })
}

【问题讨论】:

  • 可以分享一下布局代码吗?
  • 这是布局代码,是jetpack compose

标签: android android-studio kotlin android-jetpack-compose


【解决方案1】:

您可以将BottomNavWithLabels()Scaffold 一起使用:

Scaffold(topBar = { },
        bottomBar = {
            BottomNavWithLabels()
        },
        bodyContent = {
    //bodyContent()
})

【讨论】:

  • 非常感谢 Gabriele,这是否可以作为 BottomNavView 的默认实现而不是使用脚手架,我认为这就是为什么称为 BottomNavView 嗯
  • @CoffeeBreak 您可以使用BottomNavView,也可以不使用Scaffold。只需将其放入具有首选重力的另一个容器(BoxColumnRow...)中。
猜你喜欢
  • 1970-01-01
  • 2017-06-25
  • 2016-10-31
  • 2014-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-17
  • 2019-12-24
相关资源
最近更新 更多