I wrote some code which makes a view in my app appear by sliding down, I now want to run an additional animation for it to slide back up, and then set the visibility of that view to GONE
.
If I try to do that with the following code it would just set the visibility to GONE
without running the animation.
if (!isTopSheetVisible) {
pageCover.setVisibility(View.VISIBLE);
topSheet.setVisibility(View.VISIBLE);
topSheet.setTranslationY(-600);
topSheet.animate().translationY(0).setDuration(300);
isTopSheetVisible = true;
} else {
topSheet.animate().translationY(-600).setDuration(300);
pageCover.setVisibility(View.GONE);
topSheet.setVisibility(View.GONE);
isTopSheetVisible = false;
}
I tried setting a delay using Thread.sleep
and TimeUnit.sleep
, and all it did was just delaying the following lines of code, the animation still would not run.