I have my code setup as below:
What would I need to change here to not have to add the @SuppressLint?
2
If you wants to remove @SuppressLint("UnusedMaterialScaffoldPaddingParameter") warning then you have to add PaddingValues to content in Scaffold . you can write like this👇
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
PaddingValues
content
Scaffold( topBar = { MyTopBar() } ) { paddingValues -> Column(modifier = Modifier.padding(paddingValues)) { // write your content here } }
Basically PaddingValues is to provide padding to the content ( always apply paddingValues to parent composable function ).
paddingValues
Use the paddingValues on next content, it is there exactly to calculate the correct screen display for the content to come in the compose tree.
If you don’t use it, your screen will appear behind scafold elements, like the topbar or the bottombar.
Content without innerPadding set:
innerPadding
Content with innerPadding set:
Here is an example of how i use it:
{ innerPadding -> NavHost( navController, startDestination = startDestination.route, Modifier.padding(innerPadding) ) { currentScreen = navigationItems.find { it.route == currentDestination?.route } ?: startDestination composable(Screen.NotesList.route) { NotesListScreen( modifier = Modifier .fillMaxSize() .padding(horizontal = MaterialTheme.spacing.medium) ) } composable(Screen.Bin.route) { } } }
Click here to cancel reply.
2
Answers
If you wants to remove
@SuppressLint("UnusedMaterialScaffoldPaddingParameter")
warning then you have to addPaddingValues
tocontent
in Scaffold . you can write like this👇Basically
PaddingValues
is to provide padding to the content ( always applypaddingValues
to parent composable function ).Use the
paddingValues
on next content, it is there exactly to calculate the correct screen display for the content to come in the compose tree.If you don’t use it, your screen will appear behind scafold elements, like the topbar or the bottombar.
Content without
innerPadding
set:Content with
innerPadding
set:Here is an example of how i use it: