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…
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…
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…
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 =…
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…
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…
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) }
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…
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?!
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 …
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…
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…
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…
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") } …
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( …