Questions tagged [android-compose-button]
31 questions
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
24
votes
1 answer
How to create a circular Outlined button with jetpack compose
I am trying to create a circular OutlinedButton with an icon in the center without text.
OutlinedButton(onClick = { /*TODO*/ },
shape = CircleShape,
border= BorderStroke(1.dp, Color.Blue)
) {
Icon(Icons.Default.Add,…

Gabriele Mariotti
- 320,139
- 94
- 887
- 841
17
votes
1 answer
Jetpack Compose: How to disable FloatingAction Button?
According to the docs, we can disable the FAB by setting null to its onClick:
onClick - will be called when user clicked on this FAB. The FAB will
be disabled when it is null.
When I tried it I stumbled across that the onClick parameter is not…

chrgue
- 579
- 1
- 6
- 18
16
votes
2 answers
Transparent background in Outlined Button in Jetpack Compose
I want to create button where I have only text and icon and all background and borders are transparent. I create something like that:
OutlinedButton(
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent),
border =…

edi233
- 3,511
- 13
- 56
- 97
15
votes
3 answers
How to Change Button Background color on click of the button
I am trying to change the button background color on click of that button in Android jetpack compose.

SoftwareGuy
- 1,121
- 2
- 11
- 23
12
votes
4 answers
How to remove padding from Text button?
I am trying to remove padding from TextButton but it wont work.
TextButton(
onClick = {},
modifier = Modifier.padding(0.dp)
) {
Text(
" ${getString(R.string.terms_and_conditions)}",
color = MaterialTheme.colors.primary,
…

BraveEvidence
- 53
- 11
- 45
- 119
11
votes
2 answers
How to animate width of a button in Jetpack Compose
Let's say I have a Composable like this :
@Composable
fun LoadingButton() {
val (isLoading, setIsLoading) = state { false }
Button(
onClick = setIsLoading,
text = {
if (isLoading) {
Text(text =…

Kélian
- 3,323
- 3
- 11
- 20
10
votes
1 answer
How to custom the color of IconButton
I want to custom the color of IconButton instead of using the default value set on TopAppBar, but in android.compose.material there is no slot api to change it.
Scaffold(
topBar = {
TopAppBar(
title = {
…

ccd
- 5,788
- 10
- 46
- 96
9
votes
5 answers
JetPack Compose Button with drawable
How can we achieve this in jetpack compose
I'm doing something like this
Button(
elevation = ButtonDefaults.elevation(
defaultElevation = 0.dp,
pressedElevation = 8.dp,
disabledElevation = 0.dp
),
onClick = {…

Dheeraj Gupta
- 405
- 1
- 4
- 12
9
votes
6 answers
Scaling Button Animation in Jetpack Compose
I want to build this awesome button animation pressed from the AirBnB App with Jetpack Compose
Unfortunately, the Animation/Transition API was changed recently and there's almost no documentation for it. Can someone help me get the right approach…

Yannick
- 4,833
- 8
- 38
- 63
6
votes
2 answers
How to use weight in a Button to align Text on the left and Icon on the right
I'm building a re-usable Button component in Jetpack Compose, which is basically a Row. The button should have a text on the left end and an icon on the right end. This works straight forward like this:
@Composable
fun MyButton(
text: String,
…

Day
- 844
- 1
- 9
- 21
6
votes
4 answers
How to align different elements inside a Button in Jetpack Compose?
I am trying to build the following component,
Following is my code,
Button(onClick = { /*TODO*/ }, modifier = Modifier.fillMaxWidth()) {
Image(painter = painterResource(id = R.drawable.ic_check_circle) , contentDescription = "")
Text(text =…

nayan dhabarde
- 1,734
- 1
- 19
- 38
6
votes
2 answers
onPressIn and onPressOut in jetpack compose
I have button to record voice so I want it to start record when user press it and stop when he leave it
@Composable
fun Screen(){
Button(){
Text("record")
}
}

Omar Khaled
- 439
- 1
- 4
- 16
6
votes
3 answers
How to align icon in button to the left and keep text centered
I am trying to align the icon of a button to the left and keep the text centered. Any ideas how this can be achieved?
My composable:
@Composable
fun CustomButton() {
MaterialTheme {
OutlinedButton(
onClick = {},
…

Praveen P.
- 976
- 2
- 11
- 23
5
votes
1 answer
Jetpack Compose: How to avoid Button Text disappearing when Button size is small?
I am trying to create a custom button that is small and can show a numerical value between 0 and 99 as Text. Depending on the fontsize the Text disappears from the Button when the size of the Button is set too low, even though there still is space.…

bill
- 167
- 1
- 2
- 7