Questions tagged [android-compose-button]
31 questions
5
votes
1 answer
Dynamically add views on click of Button using Jetpack Compose
I want to dynamically add Text Fields to my layout everytime user click "Add" button.Added Text Field should be added above "Add" button .i.e.between Step 1 TextField and Add Button.How can this be achieved through Jetpack Compose?Below is…

Android Developer
- 9,157
- 18
- 82
- 139
4
votes
2 answers
Fix Text position in center of Jetpack Compose Button
I'm currently working on a button, which has 3 elements: An icon (with a fixed size), a title (f.e Buy Now!) and the price of the item.
The price which should be displayed is adaptive, this could be €2,00 or €2000,00. The title is supposed to be…

Bart P
- 93
- 4
3
votes
5 answers
How to detect button release after button press in Android Jetpack Compose?
I find listeners for onClick and onLongClick and even onPress but there is no event/listener for something like buttonDown and buttonUp, or onPress and onRelease.
Am I missing something? My current use case is that when a user presses a button I…

user2297550
- 3,142
- 3
- 28
- 39
3
votes
2 answers
How to set JetpackCompose Button Background Color
I tried the code in background color on Button in Jetpack Compose
Button(
onClick = { },
backgroundColor = Color.Yellow) {
}
but it doesn't recognize backgroundColor anymore.
I tried the below
Button(
modifier =…

Elye
- 53,639
- 54
- 212
- 474
2
votes
1 answer
Jetpack Compose: Is it possible to call an Composable function on a button click in another Composable function?
When I tried to write text, on a buttonClick event, I ran into the problem, that I can't call a @Composable function inside another function because of the: @Composable invocations can only happen from the context of a @Composable function error. I…

Schwoaz1802
- 35
- 10
2
votes
2 answers
Jetpack Compose UI - Button width changes on click inside AlertDialog
I'm facing this weird issue with fillMaxWidth(fraction = ...) with an AlertDialog and Button, where the Button shows up initially at one size, and on click it shrinks to wrapping its content. Here is the most basic example I can create. I've tried…

Jordan
- 1,213
- 1
- 9
- 11
2
votes
1 answer
Can I put animation fade in with duration between button state enable and disable in jetpack compose?
This is how i create my button in compose
Button(
modifier = modifier,
enabled = enabled.value,
onClick = {}
) {
Text(text = text)
}

Nirav Rangapariya
- 73
- 5
2
votes
1 answer
Text is not updating on button in Jetpack Compose
I want to change the text that's appearing on the button each time I click it, so I have written the following code, but it's not working. Where am I going wrong?
class MainActivity : ComponentActivity() {
override fun…

Praneeth Bhargav
- 29
- 6
2
votes
2 answers
Why don't Indication work for Button or Icons?
As solved here, I disable the tap flashing by setting the indication to null.
However, this is not working for Button or Icons?!

Ralf Wickum
- 2,850
- 9
- 55
- 103
2
votes
1 answer
How to set a focused state to a Button with jetpack compose?
compose_version = '1.0.0-beta02'.
I can set a focused state TextField by FocusRequester, but Button not.
val requester1 = FocusRequester()
TextField(value = text1,
{ newValue ->
text1 = newValue
…

Jin Wang
- 671
- 6
- 8
1
vote
2 answers
Make a button Unclickable from onClick
I am trying to use Compose and Kotlin in this code to make the button unclickable when counter == 3.
When I run the code and counter presumably is 3, the button stays clickable and wont change to uncklickable.
var counter = 0
var isClickable by…

abd1dab1ul
- 11
- 1
1
vote
1 answer
Jetpack compose dynamic button ID
I can change the background color of 1 single button, by pressing it and updating the relevant State, as follows:
@Composable
fun makeButtons() {
var isPressed by remember { mutableStateOf(false) }
val color = if (isPressed) Color.Red else…

Ali
- 107
- 1
- 8
1
vote
1 answer
What's a good way to prevent duplicate clicks of a button in Android Compose?
Let's say you call the signup API when a button is clicked.
Get the API response and go to the main screen.
In this case the api is called multiple times when the button is pressed repeatedly quickly.
I solved this problem to some extent using…

최정현
- 31
- 1
- 5
1
vote
1 answer
Composable disappears after clicking on button, if there is a SurfaceView in the background
setContent {
AndroidView(modifier = Modifier) {
SurfaceView(it).apply {
holder.addCallback(this@MainActivity)
}
}
Column {
Button(onClick = {}) {
Text(text = "Button")
}
…

Niklas
- 31
- 6
0
votes
1 answer
setting button background color bug?
I've tried to set the background color of buttons with custom hex values:
colors.xml:
#F67070
#00B2FF
Button(
onClick = {}
colors = ButtonDefaults.buttonColors(
…

JustSightseeing
- 1,460
- 3
- 17
- 37