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
5
votes
2 answers
Jetpack Compose expanding BottomSheet of BottomSheetScaffold only works after recomposition
I am trying to have a way to show a BottomSheet from everywhere within my app, for that I use the BottomSheetScaffold and a LiveData object that holds the current composable function which is observed as state:
val sheetContent by…

Nimmi
- 181
- 1
- 2
- 10
5
votes
1 answer
Jetpack Compose setting cursor on end of TextField
Wanna create TextField for phone number.
Need help with set cursor in field always in end of string
What i trying to do:
When got new number in field , i get all numbers that already entered, than append underscore( _ ) for have at least 11 string…

Boris Sadakov
- 617
- 1
- 7
- 18
5
votes
0 answers
How to create a global variable that can be accessed in all layers of the application. Accessing an element ID and updating
I am trying to update a text dynamically but without success. clicking on a button the text is updated

Rafael Souza
- 1,143
- 2
- 13
- 29
5
votes
3 answers
Does jetpack compose use drawable-night folder?
We have a View based Android app with some drawables in res/drawable folder, and their counterpart for night mode in res/drawable-night folder
When using legacy views, referencing a drawable R.drawable.foo from a XML layout file, the system would…

gpo
- 3,388
- 3
- 31
- 53
5
votes
3 answers
How to handle popping back multiple screens with Jetpack Compose Navigation
I'll try to do some ASCII art to describe the problem:
<--------------------------------------\
DestinationA --> DestinationC ---------> DestinationE
DestinationB ------/ \-----> DestinationD --/
I hope that's decipherable. C can be…

Sean
- 2,632
- 2
- 27
- 35
5
votes
3 answers
Access TextField value from another composable function in Jetpack Compose
I have created two TextField Email, Password & Button Login. Now on click of that button I want to access text and show success/error based on validation.
The problem is they are in two different composable functions.
@Composable
fun…

Mayur Gajra
- 8,285
- 6
- 25
- 41
5
votes
3 answers
Cannot create viewmodel from composalbe function
I have a view model.
I am using Hilt.
I can create this view model from activity, like this
val model: ProfileViewModel by viewModels()
However when I try to create this view model from a composable function
import…

Solvek
- 5,158
- 5
- 41
- 64
5
votes
1 answer
How to create a TextField with underbar, without any background or border?
I'm trying to create a TextField, in Jetpack compose with an underbar but without any other border or background. How do I do this?
This is the code I'm currently using:
val query = remember {mutableStateOf("")}
TextField(
value =…

Sparsh Dutta
- 2,450
- 4
- 27
- 54
5
votes
1 answer
AnimatedVisibility breaks constraints in ConstraintLayout in Jetpack Compose
Edit: Also happens when I swap ConstraintLayout for a Box using alignment as well...
Seems like AnimatedVisibility doesn't play well with ConstraintLayout in JP Compose at the moment.
AnimatedVisibility(
visible =…

Carter Hudson
- 1,176
- 1
- 11
- 23
5
votes
1 answer
How to use sample data in Composable?
In XML we use sample name, date etc. by using attributes like @tools:sample/first_names.
Is there any way we can use sample data similar way from @tools:sample in Preview Composable ?

Niaz Ahmed
- 220
- 2
- 12
5
votes
1 answer
How to use by delegate for mutableState yet make it passable to another function?
I have this composable function that a button will toggle show the text and hide it
@Composable
fun Greeting() {
Column {
val toggleState = remember {
mutableStateOf(false)
}
AnimatedVisibility(visible =…

Elye
- 53,639
- 54
- 212
- 474
5
votes
1 answer
Too slow loading activity Jetpack Compose
My activity loads too slow with Jetpack Compose(about 5 seconds). I have 3 screens with 1 Lazy Vertical Grid and my custom bottom navigation. Does somebody know how to parallel composing this screens or make loading activity faster?
My…

Renattele Renattele
- 1,626
- 2
- 15
- 32
5
votes
1 answer
Is there way to customize LazyRow drag or scroll behavior in android Jetpack Compose?
Below Image explains specification I want to implements
I want to make Lazy Row scroll item if user drag previous (or next) item to some X_SCROLL_THRESHOLD.
I considered to try Pager in Jetpack compose Sample app Jet Caster, but I want to show…

박찬준
- 346
- 1
- 7
5
votes
1 answer
If you are adding this ComposeView to an AppCompatActivity, make sure you are using AppCompat version 1.3+
I got this error when I upgrade my compose version from 1.0.0-beta01 to 1.0.0-beta02
(and also need to upgrade from kotlin-gradle-plugin from 1.4.30 to 1.4.31.)
java.lang.IllegalStateException: ViewTreeLifecycleOwner not set for this ComposeView.…

Elye
- 53,639
- 54
- 212
- 474
5
votes
3 answers
Change alpha when Compose Surface is being pressed (clickable modifier)
I'm using the clickable modifier on Surface and want to create a custom indication to have the surface (along with its contents) appear with 0.5 alpha when being pressed. But it seems the indication can only be used to draw additional UI.
How do I…

Brian Spilner
- 581
- 1
- 5
- 12