![]() |
VOOZH | about |
Scaffold in Android Jetpack is a composable function that provides a basic structure of the layout. It holds together different parts of the UI elements such as Application bars, floating action buttons, etc.
There are a lot of apps that contain TopAppBar, Drawer, Floating Action Button, BottomAppBar (in the form of bottom navigation), Snackbar. While you can individually set up all of these in an app it takes a lot of setups. Jetpack Compose provides Scaffold Composable which can save a lot of time. It's like a prebuilt template. In this article, we will see how to set up a Scaffold in Android with Jetpack Compose. We will be building a basic app that will demonstrate the Scaffold composable, here is a video showing the app.
Prerequisites
To create a new project in the Android Studio, please refer to How to Create a new Project in Android Studio with Jetpack Compose.
Note: Select Kotlin as the programming language.
We will be the following items in the Scaffold topBar, floatingActionButton, bottomBar and content. Let's explain how:
MainActivity.kt: