how to change statusbar color in jetpack compose?

Step 1 (add dependency) => version may change implementation “com.google.accompanist:accompanist-systemuicontroller:0.27.0” Step 2 => inside theme.kt file change the colors according to your need in the functions below. val systemUiController = rememberSystemUiController() if(darkTheme){ systemUiController.setSystemBarsColor( color = Color.Transparent ) }else{ systemUiController.setSystemBarsColor( color = Color.White ) } Step 3 => ON systemUiController you can access all types of … Read more

Using rememberCoroutineScope() vs LaunchedEffect

Leaving my understanding here: Question 1: LaunchedEffect should be used when you want that some action must be taken when your composable is first launched/relaunched (or when the key parameter has changed). For example, when you want to request some data from your ViewModel or run some sort of animation… rememberCoroutineScope on the other hand, … Read more

Jetpack Compose – Unresolved reference: observeAsState

observeAsState is part of the runtime-livedata library. Add the dependency to your module’s build.gradle file. Replace $compose_version with the version of compose which you use, e.g. 1.0.0-beta01: implementation “androidx.compose.runtime:runtime-livedata:$compose_version” You can find the available versions here in Google’s Maven repository.

When should I use Android Jetpack Compose Surface composable?

Surface composable makes the code easier as well as explicitly indicates that the code uses a material surface. Let’s see an example: Surface( color = MaterialTheme.colors.primarySurface, border = BorderStroke(1.dp, MaterialTheme.colors.secondary), shape = RoundedCornerShape(8.dp), elevation = 8.dp ) { Text( text = “example”, modifier = Modifier.padding(8.dp) ) } and the result: The same result can be … Read more

Request Focus on TextField in jetpack compose

Posting an updated Answer to the question (APIs were renamed in Compose Beta) @Composable fun AutoFocusingText() { var value by mutableStateOf(“Enter Text”) val focusRequester = remember { FocusRequester() } TextField( value = value, onValueChange = { value = it }, modifier = Modifier.focusRequester(focusRequester) ) LaunchedEffect(Unit) { focusRequester.requestFocus() } }

How to upgrade an Android project to Java 11

From Android Studio Artic Fox 2020.3.1 Preferences (Settings) -> Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JDK -> Select JDK 11 or download JDK Before Artic Fox 2020.3.1 Version I assume you have Java 11 or later installed. Following steps: File -> Project Structure -> SDK Location -> Change JDK Location to … Read more

Jetpack Compose on Kotlin 1.5.0

Update: Thanks @Samuel Luís for finding a Compose to Kotlin compatibility table https://developer.android.com/jetpack/androidx/releases/compose-kotlin Update: androidx.compose.compiler:compiler:1.0.0-beta08 is released (June 2, 2021). From this version, the expected version of Kotlin is 1.5.10. dependencies { implementation “androidx.compose.compiler:compiler:1.0.0-beta08” } android { buildFeatures { compose true } composeOptions { kotlinCompilerVersion “1.5.10” kotlinCompilerExtensionVersion “1.0.0-beta08” } kotlinOptions { jvmTarget = “1.8” } … Read more

Bottom Nav Bar overlaps screen content in Jetpack Compose

As per the API definition for Scaffold, your inner content (the trailing lambda you have your BottomNavScreensController in), is given a PaddingValues object that gives you the right amount of padding for your top app bar, bottom bar, etc. Right now, you’re not referencing that padding at all and hence, your content is not padded … Read more