Questions tagged [android-jetpack-compose]
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.
android-jetpack-compose
1,320
questions
35
votes
2
answers
54k
views
Android Jetpack Compose width / height / size modifier vs requiredWidth / requiredHeight / requiredSize
Android Jetpack Compose contains width(), height() and size() layout modifiers as well as requiredWidth(), requiredHeight() and requiredSize(). What is the difference between these two sets of ...
16
votes
1
answer
8k
views
Jetpack Compose Scoped/Smart Recomposition
I'm doing experiments to comprehend recomposition and smart recomposition and made a sample
Sorry for the colors, they are generated with Random.nextIn() to observe recomposition visually, setting ...
34
votes
5
answers
25k
views
How can I get onTouchEvent in Jetpack Compose?
In normal view, we can have onTouchEvent
override fun onTouchEvent(event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_DOWN -> {}
...
41
votes
5
answers
24k
views
Jetpack Compose - Order of Modifiers
Documentation says that Modifiers are applied from the left.
But from this example it looks like they are applied from the right:
First border and then padding because there is no space between text ...
12
votes
2
answers
11k
views
Jetpack Compose lazy column all items recomposes when a single item update
I'm trying to do some list operations and I've run into the issue of all items recomposing when a single item update.
https://prnt.sc/8_OAi1Krn-qg
My models;
data class Person(val id: Int, val name: ...
7
votes
1
answer
6k
views
How to get exact size without recomposition?
I need size of my composable to draw dynamic lines but I don't want to get size by:
var size by remember { mutableStateOf(IntSize.Zero) }
Modifier.onSizeChanged{size = it}
or
Modifier....
14
votes
3
answers
18k
views
Jetpack Compose how does SubcomposeLayout work?
As can be seen in official documents there is layout named SubcomposeLayout defined as
Analogue of Layout which allows to subcompose the actual content
during the measuring stage for example to use ...
8
votes
1
answer
5k
views
How to clip or cut a Composable?
How to clip or cut Composable content to have Image, Button or Composables to have custom shapes? This question is not about using Modifier.clip(), more like accomplishing task with alternative ...
63
votes
10
answers
59k
views
How to get activity in compose
Is there a way to get current activity in compose function?
@Composable
fun CameraPreviewScreen() {
val context = ContextAmbient.current
if (ActivityCompat.checkSelfPermission(
...
14
votes
5
answers
7k
views
Why the view keeps flashing when using jetpack navigation with Compose?
I have a login scren and when the login is successful and the view model updates the mutable state variable, my expectation is that a new composable function is called to show a new screen and the ...
11
votes
2
answers
4k
views
Why does mutableStateOf without remember work sometimes?
I've been playing with Jetpack Compose Desktop. I noticed something I really don't understand:
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.material.Button
import ...
49
votes
11
answers
31k
views
How can I detect keyboard opening and closing in jetpack compose?
The only way I've found in compose is to use accompanist-insets and that removes window insets. And such causes other problems with my app's layout.
The Android way seems to be this and I could pass ...
46
votes
12
answers
36k
views
Jetpack Compose collapsing toolbar
I can't find any documents on the matter, is there something similar to a CollapsingToolbar in Compose?
All I found was a mention of it here, but nothing on how to set it up
101
votes
17
answers
57k
views
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 ...
8
votes
3
answers
14k
views
Different types of width in jetpack compose
I am working in textfield in jetpack compose. I want to build something like this
TextField(
value = value,
onValueChange = {
value = it
},
...