admin管理员组文章数量:1124537
Is there any top app bar composable in Android with Jetpack Compose where the value of the 'title' parameter is not mandatory?
I asked an LLM, and it suggested using SmallTopAppBar()
, but I am facing an issue with its import statement: import androidxpose.material3.SmallTopAppBar
. The LLM also recommended adding a dependency: implementation("androidxpose.material3:material3:1.3.1")
. I synced my Gradle file with this dependency, but nothing works. The problem shown in studio was: Unresolved Reference
Please help...
Is there any top app bar composable in Android with Jetpack Compose where the value of the 'title' parameter is not mandatory?
I asked an LLM, and it suggested using SmallTopAppBar()
, but I am facing an issue with its import statement: import androidx.compose.material3.SmallTopAppBar
. The LLM also recommended adding a dependency: implementation("androidx.compose.material3:material3:1.3.1")
. I synced my Gradle file with this dependency, but nothing works. The problem shown in studio was: Unresolved Reference
Please help...
Share Improve this question edited yesterday Rokata 1,23114 silver badges34 bronze badges asked 2 days ago blowingMyBody...blowingMyBody... 33 bronze badges New contributor blowingMyBody... is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 1There is no SmallTopAppBar
Composable, this is just the name of this kind of top app bar, which maps to the TopAppBar
Composable.
You will continuously stumble across this type of inaccuracies if you solely rely on LLM. I would suggest that you make yourself familiar with the Jetpack Compose documentation:
- App Bars Documentation
- Material3 Composables
- Jetpack Compose Basics Codelab
Also, if you generate a project using the Jetpack Compose Template in Android Studio, it will generate a project that has all important dependencies set up already, including the material3 dependency:
Besides that, you can just leave the title
parameter empty for all sorts of TopAppBars:
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TopAppBarDemo() {
Column(
modifier = Modifier.fillMaxWidth()
) {
LargeTopAppBar(
title = {},
navigationIcon = {
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "")
},
actions = {
Icon(Icons.Default.MoreVert, "")
}
)
MediumTopAppBar(
title = {},
navigationIcon = {
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "")
},
actions = {
Icon(Icons.Default.MoreVert, "")
}
)
CenterAlignedTopAppBar(
title = {},
navigationIcon = {
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "")
},
actions = {
Icon(Icons.Default.MoreVert, "")
}
)
TopAppBar(
title = {},
navigationIcon = {
Icon(imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "")
},
actions = {
Icon(Icons.Default.MoreVert, "")
}
)
}
}
Output:
版权声明:本文标题:I am having a problem with the Top App Bar in Android development using Jetpack Compose - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736638956a1945948.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论