Animate an arbitrary set of UI changes in Android

15 Views Asked by At

For context, this is an SDK that is installed on client apps.

I have a callback that is provided by the client app, and specifies a series of layout changes. This typically involves increasing the heigh of a view, and adjusting the position of other views to account for that. At it's simplest, it might look like:

val UICallback = {
    val params: ConstraintLayout.LayoutParams = view.layoutParams as ConstraintLayout.LayoutParams
    params.height = height
    view.layoutParams = params
}

I would like to animate the UI changes made by this callback, but the catch is that I have know way of knowing what the changes actually are.

In iOS, I'm able to use UIView.animate like so:

UIView.animate(withDuration: 5) {
   UICallback()
   window?.layoutIfNeeded()
}

So my main question is, is there a way I can do the same thing in Android? Is there a way I can execute an arbitrary block of UI changes, and have those changes animate smoothly?

0

There are 0 best solutions below