setTransitionListener中设置原本gone的view为visible,view仍旧不可见。
必须post中设置。具体原因暂未可知。
clRoot.setTransitionListener(new TransitionAdapter() {
@Override
public void onTransitionChange(MotionLayout motionLayout, int startId, int endId, float progress) {
super.onTransitionChange(motionLayout, startId, endId, progress);
//view.setVisibility(View.Visible);//无效
clRoot.post((Runnable) () -> {
view.setVisibility(View.Visible);//有效
});
}
@Override
public void onTransitionCompleted(MotionLayout motionLayout, int currentId) {
super.onTransitionCompleted(motionLayout, currentId);
clLeftMenu.setTranslationX(0);
}
});