0

I come to ask you for help concerning a small problem I can't find the solution. I'm making a small application in Jetpack Compose, and I can't get the TopAppBar to disappear and leave only the part that slides up. This is a screenshot: screenshot

Here is my code:

@Composable
fun Test2() {
    val topAppBarElementColor = MaterialTheme.colors.onPrimary
    var scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior(rememberTopAppBarState())
    Scaffold(
        topBar = {
            LargeTopAppBar(
                title = { Text(text = "TopBar") },
                navigationIcon = { IconButton(onClick = { /*TODO*/ }) { Icon(imageVector = Icons.Default.Menu, contentDescription = "") } },
            scrollBehavior = scrollBehavior
            )

        },
        modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection)
    ) { innerPadding ->
        LazyColumn(
            modifier = Modifier
                .fillMaxSize()
                .padding(innerPadding)
        ) {
            items((1..50).toList()) { item ->
                Text(modifier = Modifier.padding(8.dp), text = "Item $item")
            }
        }
    }
}```
zou naa
  • 1
  • 4

1 Answers1

0

This code works fine for me. There's probably something else out of that function that's causing this issue. This top app bar is from Material 3, so make sure everything that's being called in that code is imported from the package androidx.compose.material3.*, and not from androidx.compose.material.*.

cd1
  • 15,908
  • 12
  • 46
  • 47
  • Yes this code works fine, but i just want to remove the First top bar and Keep the second one who slides up … – zou naa Apr 21 '23 at 17:16
  • Exactly, you should only see one text if you use the correct functions and themes. Have you checked if every single import line is pointing to `material3.*` and not to `material.*`? – cd1 Apr 21 '23 at 17:44
  • Yes :import androidx.compose.material3.* – zou naa Apr 22 '23 at 10:20