Android Studio 如何使用Jetpack合成在选定的底部导航项图标周围实现这种圆角形状

jjhzyzn0  于 2022-11-16  发布在  Android
关注(0)|答案(1)|浏览(124)



这是我的BottomNavigaionItem的外观。

BottomNavigationItem(
                selected = selected,
                onClick = {...}
                icon = {
                        Icon(
                            imageVector = if (selected) navItem.iconFilled else navItem.iconOutlined,
                            contentDescription = navItem.route,
                           // modifier = Modifier.background(Color.DarkGray, shape = RoundedCornerShape(10.dp)).padding(10.dp)
                        )
                },
                label = {...},
                selectedContentColor = MaterialTheme.colors.onPrimary,
                unselectedContentColor = MaterialTheme.colors.onPrimary.copy(0.4f)
            )
        }
    }
qzwqbdag

qzwqbdag1#

只需使用M3和NavigationBar

NavigationBar {
    items.forEachIndexed { index, item ->
        NavigationBarItem(
            icon = { Icon(Icons.Filled.Favorite, contentDescription = item) },
            label = { Text(item) },
            selected = selectedItem == index,
            onClick = { selectedItem = index }
        )
    }
}

相关问题