Reputation: 5468
I have Toolbar
with TabLayout
which I'd like to hide/show at some points, I'd like to animate the hide/show process of the tabs (The toolbar remains visible)... putting a scale animation on the TabLayout
hides it but the height of the toolbar remains the same, as if the tabs are 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);
}
}
Upvotes: 4
Views: 5690
Reputation: 164
You need to set android:animateLayoutChanges="true"
to your AppBarLayout
and in your JAVA just use tablLayout.setVisibility(View.VISIBLE)
and tablLayout.setVisibility(View.GONE)
for visibility and enjoy the result!
Upvotes: 6