Home » Android » java – Is there a way to disable MotionLayout visiblity changes animation?-Exceptionshub

java – Is there a way to disable MotionLayout visiblity changes animation?-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

In my MotionScene I have transition which lasts for several seconds. In ConstraintSet I have a view that is invisible that I want to make visible when the transition is done. But I don’t want to animate the view going from Visibility.GONE to Visibility.VISIBLE. Is there a way to stop that?

If needed I can provide code, but it’s not that complex. It’s just a transition with two ConstraintSet-s, this View is in both sets in starting set it’s visibility="visible", and in ending set it’s visibility = "gone"

Does anybody have any suggestions?

EDIT: I should note that I did put
android:animateLayoutChanges="false"
in root layout of the activity that uses this MotionScene.

How to&Answers:

If i understand your problem, you can use alpha animation like this;

AlphaAnimation animation1 = new AlphaAnimation(1f, 0.3f);
animation1.setDuration(1000);
animation1.setFillAfter(true);
yourView.startAnimation(animation1);