I have a simple scale animation:
val x = PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 2f)
val y = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 2f)
val grow = ObjectAnimator.ofPropertyValuesHolder(imageViews[j].starViews[3], x, y).apply {
duration = 5000
}
imageView[].visibility = View.VISIBLE
AnimatorSet().play(grow)
It works well when I add it to my onTouchListener. But when I add it to the onLongClickListener, it doesn't work. It only gets visible, and animation doesn't happen
imageViews[j].starViews[2].setOnLongClickListener {
if (!imageViews[j].done && imageViews[j].intermediate) {
//The onTouchListener also has this if condition
val x = PropertyValuesHolder.ofFloat(View.SCALE_X, 0f, 2f)
val y = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f, 2f)
val grow = ObjectAnimator.ofPropertyValuesHolder(imageView, x, y).apply {
duration = 5000
}
imageView.visibility = View.VISIBLE
AnimatorSet().apply {
Log.d("animCall", "called")
play(grow)
}
return@setOnLongClickListener true
}
return@setOnLongClickListener false
}