animateVisibility

fun View.animateVisibility(newVisibility: Int?, enterAnimation: Animation?, exitAnimation: Animation?)

Starts animations based on the View visibility (newVisibility).

For this to work, both enterAnimation and exitAnimation must be specified.

If the view visibility is set to View.VISIBLE, the enterAnimation is started. If the view visibility is set to View.INVISIBLE or View.GONE, the exitAnimation is started.

No animations are started if the newVisibility is null or if the values are set for the very first time.

Example usage:

<View
android:visibility="@{viewModel.isViewVisible ? View.VISIBLE : View.GONE}"
auto:enterAnimation="@{@anim/tt_enter_slideup}"
auto:exitAnimation="@{@anim/tt_exit_slidedown}" />