When switching to a fragment, the animation does not work
Here is the code:
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View contentView = inflater.inflate(R.layout.activity_main2, container, false); slideUp = contentView.findViewById(R.id.slideup); slideDown = contentView.findViewById(R.id.slideDown); line_item = contentView.findViewById(R.id.scan_item); slideDown.animate().setDuration(DURATION).translationYBy(slideDown.getHeight()); return contentView; }