Jetpack Compose is Android’s modern toolkit for building native declarative UI made by Google. If you're targeting desktop with Compose for Desktop, use both this and [compose-desktop] tags.
Questions tagged [android-jetpack-compose]
10142 questions
80
votes
6 answers
What is the difference between "remember" and "mutableState" in android jetpack compose?
I'm new in jetpack compose and trying to understand the difference between remember and mutableStateOf
In other words the deference between this line
val text = remember{ mutableStateOf("") }
and this
val text = remember{ "" }
and this also
val…

Ahmed Abdalla
- 2,356
- 2
- 14
- 27
79
votes
3 answers
When should I use Android Jetpack Compose's Surface composable?
There's a Surface composable in Jetpack Compose which represents a material surface. A surface allows you to set up things like background color or border but it seems that the same might be done using modifiers. When should I use the Surface…

Valeriy Katkov
- 33,616
- 20
- 100
- 123
78
votes
6 answers
Bottom Nav Bar overlaps screen content in Jetpack Compose
I have a BottomNavBar which is called inside the bottomBar of a Scaffold.
Every screen contains a LazyColumn which displays a bunch of images.
For some reason when I finish scrolling, the BottomNavBar overlaps the lower part of the items list.
How…

Gianluca Veschi
- 1,239
- 1
- 14
- 20
75
votes
9 answers
How to upgrade an Android project to Java 11
I am using the latest Android Studio Arctic Fox 2020.03.01 Canary 8 and AGP 7, and I want to convert my project to use Java 11. Apparently just doing the following does not work as mentioned on…

azfar
- 751
- 1
- 4
- 3
73
votes
3 answers
Jetpack Compose - Unresolved reference: observeAsState
I'm learning Jetpack Compose and I was trying to make a View Model for my @Composable.
In documentation (https://developer.android.com/codelabs/jetpack-compose-state#3) for observing state changes in composable they use observeAsState but in my…

Valentin
- 1,159
- 1
- 11
- 22
71
votes
8 answers
background color on Button in Jetpack Compose
Button(backgroundColor = Color.Yellow) {
Row {
Image(asset = image)
Spacer(4.dp)
Text("Button")
}
}
I can not figure out why I can't use background color on Button.
I followed the Compose Layout codelabs.
There is a…

shotmeinthehead
- 779
- 1
- 4
- 10
71
votes
6 answers
How to create rounded border Button using Jetpack Compose
I need to add border with rounded corner in Button using Jetpack Compose
Like :

Sanjayrajsinh
- 15,014
- 7
- 73
- 78
70
votes
12 answers
Jetpack Compose Text hyperlink some section of the text
How can i add hyperlink to some section of the text of Text component?
With buildAnnotatedString i can set link section blue and underlined as in image below, but how can i also turn that section into link?
val annotatedLinkString =…

Thracian
- 43,021
- 16
- 133
- 222
69
votes
7 answers
Match Width of Parent in Column (Jetpack Compose)
By default, Column {} has the width of it's largest child element. How can I make all other elements to fit the width of the parent Column? If I use Modifier.fillMaxWidth() the elements will take up the entire available space and make the parent…

Yannick
- 4,833
- 8
- 38
- 63
68
votes
1 answer
How can I specify an exact amount of spacing between children in a Jetpack Compose Column?
I am trying to create a Column in Jetpack Compose with a specific amount of spacing between each child element, such as 10.dp. In SwiftUI, this is relatively simple. I would just create a VStack with a spacing value:
struct ContentView: View {
…

Eugene
- 3,417
- 5
- 25
- 49
68
votes
19 answers
how to change statusbar color in jetpack compose?
how to make status bar color transparent in compose like here:
it has the same color but with a little bit shade.

Nurseyit Tursunkulov
- 8,012
- 12
- 44
- 78
67
votes
15 answers
Jetpack Compose on Kotlin 1.5.0
I've updated to Kotlin 1.5 last week, and after yesterday having seen the intention of Google to make Jetpack Compose the preferred option for designing UIs, I wanted to do some testing.
The issue is that having my project updated to Kotlin 1.5,…

Arnyminer Z
- 5,784
- 5
- 18
- 32
66
votes
3 answers
Toggle password field jetpack compose
Hi I am trying to change visualTransformation dynamically when the user click on see password button. I can manage to filter password but couldn't achive to show in plain text. Any idea for that ? Here is what I got so far.
fun UserInputText(
…

clouddy
- 891
- 2
- 8
- 10
66
votes
2 answers
Draw a line in jetpack compose
Using XML layout, you could use a View object with colored background to draw a line.
How can we draw a horizontal or vertical line in Jetpack compose?

Mahdi-Malv
- 16,677
- 10
- 70
- 117
65
votes
7 answers
Jetpack compose - how do I refresh a screen when app returns to foreground
I need to automatically refresh an Android Compose screen when the app returns to the foreground.
I have an that requires permissions and location services.
If the user has switched any of these off a list is drawn of the items that need to be…

William
- 1,255
- 2
- 10
- 9