Duration is not working when changing height.
oscargrgm opened this issue · 2 comments
oscargrgm commented
I'm trying to animate height
changing and duration
parameter is ignored. This is my code:
val height = View.MeasureSpec.makeMeasureSpec(this.height, View.MeasureSpec.EXACTLY)
ViewPropertyObjectAnimator.animate(this)
.heightBy(0)
.height(height)
.setDuration(duration)
.start()
The point is when I set final height to 0, it works perfectly:
val height = View.MeasureSpec.makeMeasureSpec(this.height, View.MeasureSpec.EXACTLY)
ViewPropertyObjectAnimator.animate(this)
.heightBy(height)
.height(0)
.setDuration(duration)
.start()
Any suggestion?
blipinsk commented
Hi @oscargrgm,
there are two things you are misusing:
MeasureSpec
is not a measure of height. It's something that "encapsulates the layout requirements passed from parent to child". It is used within theonMeasure
method of theView
. Read more here: https://developer.android.com/reference/android/view/View.MeasureSpec- You're using
heightBy
andheight
at the same time which makes no sense.heightBy
is a method to animate the height of a View by a particular height "diff".height
animatesView
to an absolute value.
Resolve those two issues, and let me know if it helped or not. For now, I'm closing this issue.
oscargrgm commented
Ok, you were right. I removed heightBy
and now I'm getting the view's height in a different way an works perfectly. Thank you very much!