//这里是设置的高拉伸动画
val viewLWrapper = ViewHWrapper(anyView)
val ofInt = ObjectAnimator.ofInt(viewLWrapper, "trueHeight", 800, 0)
ofInt.addListener(object : Animator.AnimatorListener{
override fun onAnimationStart(p0: Animator?) {
}
override fun onAnimationEnd(p0: Animator?) {
sxLayout.gone()
}
override fun onAnimationCancel(p0: Animator?) {
}
override fun onAnimationRepeat(p0: Animator?) {
}
})
ofInt.setDuration(300).start()
private class ViewHWrapper(private val mTarget: View) {
//必须调用,不然高度改变,UI不会刷新
var trueHeight: Int
get() = mTarget.layoutParams.height
set(height) {
mTarget.layoutParams.height = height
mTarget.requestLayout() //必须调用,不然高度改变,UI不会刷新
}
}