Skip to content

Instantly share code, notes, and snippets.

@rezaiyan
Last active September 19, 2017 03:42
Show Gist options
  • Save rezaiyan/bfe4fec888240fc182cbb78142101a57 to your computer and use it in GitHub Desktop.
Save rezaiyan/bfe4fec888240fc182cbb78142101a57 to your computer and use it in GitHub Desktop.
Animate tabs of Tablayout with add or removing tabs programmatically
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