#java #android #animation #kotlin
#java #Android #Анимация #kotlin
Вопрос:
Я хочу анимировать journeyText: TextView
с левой стороны после завершения всех остальных анимаций. Но journeyText
виден во время запуска, а затем происходит анимация.
Я сделал следующее:
val animator1 = ObjectAnimator.ofFloat(circularFace, "translationY", 2000f,0f)
animator1.repeatCount = 0
animator1.duration = 1000
val animator2 = ObjectAnimator.ofFloat(happyBdayText, "translationX", -2000f, 0f)
animator2.repeatCount = 0
animator2.duration = 1000
val animator3 = ObjectAnimator.ofFloat(journeyText, "translationX", -2000f, 0f)
animator3.repeatCount = 0
animator3.duration = 2000
animator3.startDelay = 5000
val set = AnimatorSet()
set.play(animator1)
set.play(animator2)
set.play(animator3)
set.start()
Я пытался настроить видимость, но это не работает.
Ответ №1:
Вы могли бы просто уменьшить свое startDelay
значение.
package com.example.myapplication
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val textView = findViewById<TextView>(R.id.text)
val animator1 = ObjectAnimator.ofFloat(textView, "translationY", 2000f, 0f)
animator1.repeatCount = 0
animator1.duration = 1000
val textTwo = findViewById<TextView>(R.id.texttwo)
val animator2 = ObjectAnimator.ofFloat(textTwo, "translationX", -2000f, 0f)
animator2.repeatCount = 0
animator2.duration = 1000
val textThree = findViewById<TextView>(R.id.textThree)
val animator3 = ObjectAnimator.ofFloat(textThree, "translationX", -2000f, 0f)
animator3.repeatCount = 0
animator3.duration = 2000
animator3.startDelay = 1
val set = AnimatorSet()
set.play(animator1)
set.play(animator2)
set.play(animator3)
set.start()
}
}