Last active
September 19, 2017 03:42
-
-
Save rezaiyan/bfe4fec888240fc182cbb78142101a57 to your computer and use it in GitHub Desktop.
Animate tabs of Tablayout with add or removing tabs programmatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void addTab(TextView tv) { | |
View v = tab.getCustomView(); | |
if (v instanceof TextView) { | |
tv.setScaleX(0f); | |
tv.setScaleY(0f); | |
tv.animate() | |
.scaleX(1f) | |
.scaleY(1f) | |
.setInterpolator(new FastOutSlowInInterpolator()) | |
.setDuration(450) | |
.start(); | |
} | |
} | |
private void removeTab(TabLayout.Tab tab, final int index) { | |
View v = tab.getCustomView(); | |
if (v instanceof TextView) { | |
v.setScaleX(1f); | |
v.setScaleY(1f); | |
v.animate() | |
.scaleX(0f) | |
.scaleY(0f) | |
.setInterpolator(new FastOutSlowInInterpolator()) | |
.setDuration(450) | |
.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment