[Android Jetpack] Creating Fullscreen Loading dialog using Jetpack Compose.
1 min readOct 11, 2022
A very simple but useful content. Something that can save your few hours of development time.
I’ll share a simple code that will help you create a common fullscreen loading screen in your whole project.
- We will create a LoadingIndicator Composable function
- Will use that function to create the loading screen
- will add a preview function as well.
- DialogContent
@Composable
fun DialogContent() {
Box(
modifier = Modifier
.size(76.dp)
.background(
color = Color.White,
shape = RoundedCornerShape(4.dp)
)
) {
CircularProgressIndicator(
modifier = Modifier
.align(
Alignment.Center
),
color = Color.Red
)
}
}
2. Using DialogContent creating a fullscreen loading screen.
@Composable
fun LoadingDialog(isShowingDialog: Boolean, dismissOnBackPress: Boolean = false, dismissOnClickOutside: Boolean = false) {
if (isShowingDialog) {
Dialog(
onDismissRequest = { },
DialogProperties(
dismissOnBackPress = dismissOnBackPress,
dismissOnClickOutside = dismissOnClickOutside
)
) {
DialogContent()…