animateVisibleIfNot

fun View.animateVisibleIfNot(condition: Boolean?, enterAnimation: Animation?, exitAnimation: Animation?)

Starts animations based on the View visibility. The visibility is based on whether the condition is satisfied.

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

If the condition is not satisfied (false) or null, the visibility is set to View.VISIBLE and the enterAnimation is started. If the condition is not satisfied (true), the exitAnimation is started and the visibility is set to View.GONE.

No animations are started if the values are set for the very first time.

Example usage:

<View
auto:visibleIfNot="@{viewModel.condition}"
auto:enterAnimation="@{@anim/tt_enter_slideup}"
auto:exitAnimation="@{@anim/tt_exit_slidedown}" />