Skip to content

Commit 5051874

Browse files
committed
Add workaround for top app bar overlapping nav rail
1 parent 1c6c812 commit 5051874

File tree

1 file changed

+6
-0
lines changed
  • app/src/main/java/com/google/samples/apps/nowinandroid/ui

1 file changed

+6
-0
lines changed

app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaApp.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import androidx.compose.ui.res.painterResource
4848
import androidx.compose.ui.res.stringResource
4949
import androidx.compose.ui.semantics.semantics
5050
import androidx.compose.ui.semantics.testTagsAsResourceId
51+
import androidx.compose.ui.zIndex
5152
import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
5253
import androidx.lifecycle.compose.collectAsStateWithLifecycle
5354
import androidx.navigation.NavDestination
@@ -110,6 +111,11 @@ fun NiaApp(
110111
val destination = appState.currentTopLevelDestination
111112
if (destination != null) {
112113
NiaTopAppBar(
114+
// When the nav rail is displayed, the top app bar will, by default
115+
// overlap it. This means that the top most item in the nav rail
116+
// won't be tappable. A workaround is to position the top app bar
117+
// behind the nav rail using zIndex.
118+
modifier = Modifier.zIndex(-1F),
113119
titleRes = destination.titleTextId,
114120
actionIcon = NiaIcons.Settings,
115121
actionIconContentDescription = stringResource(

0 commit comments

Comments
 (0)