Questions tagged [android-compose-appbar]
15 questions
48
votes
5 answers
@composable invocations can only happen from the context of an @composable function
I'm trying to show a toast message when clicking on a toolbar action, but I got this error
@composable invocations can only happen from the context of an
@composable function
Code:
@Composable
fun Toolbar() {
TopAppBar(title = { Text(text =…

SNM
- 5,625
- 9
- 28
- 77
20
votes
11 answers
How to align title at layout center in TopAppBar?
TopAppBar(
backgroundColor = Color.Transparent,
elevation = 0.dp,
modifier= Modifier.fillMaxWidth(),
navigationIcon = {
IconButton(
onClick = { TODO },
enabled = true,
…

Bpn
- 463
- 1
- 4
- 11
19
votes
5 answers
Does Android Jetpack Compose support Toolbar widget?
I'd like to use Toolbar with Jetpack Compose. Does it have such a Composable component?

Commander Tvis
- 2,244
- 2
- 15
- 41
14
votes
2 answers
Add drawer toggle button in Jetpack compose
I want to add the hamburger icon to the Appbar and open/close drawer using the icon.
How would I achieve this?
Scaffold(
drawerShape = RoundedCornerShape(topRight = 10.dp, bottomRight = 10.dp),
drawerElevation = 5.dp,
drawerContent = {
…

Mahdi-Malv
- 16,677
- 10
- 70
- 117
4
votes
2 answers
TopAppBar not adjusting height automatically in Compose and TabRow not working
Basically, I have two composable funcs which create a TopAppBar and add a tab layout contained in the app bar :
@Composable
fun ZCryptAppBar(
modifier: Modifier = Modifier,
title: @Composable RowScope.() -> Unit
) {
…

ScarySneer
- 199
- 3
- 9
4
votes
2 answers
Toolbar structured behavior for Jetpack Compose
Imagine the usual behavior of a toolbar in Android.
You define a Toolbar widget in the Activity, and can access it using onCreateOptionsMenu and onOptionsItemSelected inside your fragments.
However, something like this is not possible with normal…

Ahmad Sattout
- 2,248
- 1
- 19
- 42
4
votes
1 answer
Jetpack Compose TopBar and BottomBar Default Elevation content doesn't fill its container
How do I fix the topbar and bottombar doesn't fill up its container.
The topbar and bottombar uses the default Elevation respectively
You can see the Top bar doesn't fill max width and it got shadows, while the bottom bar have the text its own…

Arthur
- 318
- 1
- 4
- 11
4
votes
1 answer
Issue with ConstraintLayout in Jetpack compose
I am trying to setup a constraint layout with appbar at top, list in middle and some xml resource at bottom using jetpack compose. below is my code
ConstraintLayout(
modifier = Modifier
.fillMaxWidth()
){
…

Bharat Kumar
- 806
- 14
- 22
4
votes
2 answers
How can i add a Toolbar in Jetpack Compose?
I need to add a Toolbar in my Android application with a List like below. I am using Jetpack Compose to create the UI. Below is the composable function i am using for drawing the main view.
@Composable
fun HomeScreenApp() {
showPetsList(dogs =…

Ajith M A
- 3,838
- 3
- 32
- 55
3
votes
1 answer
MediumTopAppBar Material3 change only big Title
I am working with MediumTopAppBar, and i am trying to change the textStyle of the big Title without ruining the small title.
So what i am doing is:
MediumTopAppBar(
title = { HeadlineLargeBlackText(text = "pageTitle") },
…

Meyben
- 451
- 3
- 15
3
votes
3 answers
Change TopAppBar background color from themes.xml
In Jetpack Compose, TopAppBar shows default background color irrespective of what we added to themes.xml.
So how can we change TopAppBar background color from themes.xml so it's applied globally to the App?
TopAppBar(
title = { Text("Activity")…

Nikunj
- 3,937
- 19
- 33
2
votes
2 answers
TopAppBar in jetpack compose without scaffold gives error
TopAppBar(title = { Text(text = "Notes") },actions = {Icon(imageVector =Icons.Default.Notifications,contentDescription = "Notif",)},) {}
when I try running the above code I get the following error "None of the following functions can be called with…

sanjay_siddharth
- 23
- 2
2
votes
3 answers
How to pass conditional parameter in Jetpack Compose?
I want to hide the navigationIcon but when I pass null or Unit the icon space remains visible, as can be seen in the image below.
@Composable
fun DefaultScaffold(
title: String? = null,
icon: ImageVector? = null,
content: @Composable()…

Gustavo Faria
- 181
- 2
- 6
0
votes
2 answers
How to specify Arrangement.SpaceEvenly in a BottomAppBar?
This is the prototype of Row:
@Composable
public inline fun Row(
modifier: Modifier = Modifier,
horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
verticalAlignment: Alignment.Vertical = Alignment.Top,
content:…

ceving
- 21,900
- 13
- 104
- 178
0
votes
2 answers
Why is TopAppBar navigationIcon's not a composable function?
My IDE is showing that navigationIcon is not a composable function. Other people are doing the same thing. I'm getting this error
@composable invocations can only happen from the context of an @composable function
@Composable
fun AppBar(onClick:…

Chris Basinger
- 23
- 5