Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

227
Vistas
Is there any APIs that applys the same thing into different views in Kotlin?

I have 3 buttons that has the same animation.

let's call them, button1, button2, button3.

button1
    .animate()
    .setDuration(initialTime)
    .setInterpolator(DecelerateInterpolator())
    .alpha(1f)
    .start()
button2
    .animate()
    .setDuration(initialTime)
    .setInterpolator(DecelerateInterpolator())
    .alpha(1f)
    .start()
button3
    .animate()
    .setDuration(initialTime)
    .setInterpolator(DecelerateInterpolator())
    .alpha(1f)
    .start()

But this is too long. I need something like...

with(button1+button2+button3).apply{
    this.animate()
    .setDuration(initialTime)
    .setInterpolator(DecelerateInterpolator())
    .alpha(1f)
    .start()
}

This will be clearer and simpler. I could make a list of the views but this method is also longer and massier.

Is there any features like that in Kotlin?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

val buttons = listOf(button1, button2, button3)
buttons.forEach { 
    it.animate()
    .setDuration(initialTime)
    .setInterpolator(DecelerateInterpolator())
    .alpha(1f)
    .start()
}
over 4 years ago · Santiago Trujillo Denunciar

0

extension function

fun Button.setUp() {
    this.animate()
        .setDuration(initialTime)
        .setInterpolator(DecelerateInterpolator())
        .alpha(1f)
        .start()
}
button1.setUp()
button2.setUp()
button3.setUp()
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda