Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Jetpack Compose fila inclinada con botones

Estoy desarrollando una aplicación para Android en Jetpack Compose, que es básicamente un formulario grande. Quería agregarle un poco de estilo con botones personalizados, pero realmente no sé cómo hacerlos.

Lo que estoy tratando de lograr:

Ejemplo de estilo de botón

En ese diseño habrá 2 botones con un campo de texto en el medio. ¿Cómo puedo inclinarlos para que se vea como la imagen?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Puedes construir una forma personalizada como esta:

 class ParallelogramShape(private val angle: Float): Shape { override fun createOutline( size: Size, layoutDirection: LayoutDirection, density: Density, ) = Outline.Generic( Path().apply { val width = size.width - size.height / tan(angle) moveTo(size.width - width, 0f) lineTo(size.width, 0f) lineTo(width, size.height) lineTo(0f, size.height) lineTo(size.width - width, 0f) } ) }

Y utilízalo así:

 val border = BorderStroke(1.dp, Color.Black) val shape = ParallelogramShape(45f) Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier .padding(10.dp) .border(border, shape = shape) ) { var counter by remember { mutableStateOf(10) } TextButton( onClick = { counter -= 1 }, shape = shape, border = border, modifier = Modifier .height(45.dp) .width(100.dp) ) { Text("-") } Text(counter.toString()) TextButton( onClick = { counter += 1 }, shape = shape, border = border, modifier = Modifier .height(45.dp) .width(100.dp) ) { Text("+") } }

Resultado:

over 4 years ago · Santiago Trujillo Report

0

Esto es lo que pude lograr.

ingrese la descripción de la imagen aquí

Necesita dos IconButton o Image para incrementar y disminuir el valor del número en TextField .

Utilice Row para organizar los elementos horizontalmente.

Declare un Int para realizar un seguimiento del valor que sigue cambiando con rememberSaveable .

 var numberValue: Int by rememberSaveable { mutableStateOf(15) }

Ahora finalmente todos los elementos dentro de una fila.

 Row( Modifier.background(color = Color.LightGray), verticalAlignment = Alignment.CenterVertically ) { IconButton(onClick = { numberValue - 1 }) { Icon( imageVector = Icons.Rounded.KeyboardArrowDown, tint = Color.Black, contentDescription = null ) } TextField( value = "$numberValue", onValueChange = { numberValue = it.toInt() }, singleLine = true, keyboardOptions = KeyboardOptions( keyboardType = KeyboardType.Number, ), maxLines = 1, modifier = Modifier .width(60.dp) .background(Color.Gray, RectangleShape) .border(1.dp, Color.Gray, RectangleShape), ) IconButton(onClick = { numberValue + 1 }) { Icon( imageVector = Icons.Rounded.KeyboardArrowUp, tint = Color.Black, contentDescription = null ) } }

Reemplace los íconos que he usado en ambos IconButton con los suyos. Tome tomar para comprender todos los atributos en TextField .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!