Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
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 Respostas
Responde à pergunta

0

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

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda