TabLayout hide / show animation

I have Toolbarwith TabLayoutwhich I would like to hide / show at some points, I would like to animate the process of hide / show tabs (the toolbar remains visible) ... a large-scale animation does not TabLayouthide it, but the height of the toolbar remains the same, as if the tabs were there ... any suggestions?

 public void showTabs(boolean show) {
        if (show) {
          //tabLayout.setVisibility(View.VISIBLE);
            tabLayout.animate().scaleY(1).setInterpolator(new DecelerateInterpolator()).start();

        } else {
            tabLayout.animate().scaleY(0).setInterpolator(new AccelerateInterpolator()).start();
            //tabLayout.setVisibility(View.GONE);
        }
    }
+4
source share
1 answer

You need to install android:animateLayoutChanges="true"on AppBarLayout, and in your JAVA just use tablLayout.setVisibility(View.VISIBLE)both tablLayout.setVisibility(View.GONE)for visibility and enjoy the result!

+6
source

Source: https://habr.com/ru/post/1614108/


All Articles