Created
April 4, 2021 23:35
-
-
Save oluwabajio/4ee4045a62dc856e6cd0eefcd35eeddc to your computer and use it in GitHub Desktop.
Animation Helper class
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
public class AnimatorHelper { | |
private static final int DURATION_LIST = 700; | |
public static void buttonVanish(View... views){ | |
for(final View view:views){ | |
view.setEnabled(false); | |
view.animate() | |
.scaleX(0) | |
.scaleY(0) | |
.setDuration(DURATION_LIST) | |
.withEndAction(new Runnable() { | |
@Override | |
public void run() { | |
view.setVisibility(View.INVISIBLE); | |
} | |
}).start(); | |
} | |
} | |
public static void buttonEmerge(View... views) { | |
for (final View view : views) { | |
view.setVisibility(View.VISIBLE); | |
view.animate() | |
.scaleX(1) | |
.scaleY(1) | |
.setDuration(DURATION_LIST) | |
.withEndAction(new Runnable() { | |
@Override | |
public void run() { | |
view.setEnabled(true); | |
} | |
}) | |
.start(); | |
} | |
} | |
public static void listVanish(View... views) { | |
for(final View view: views){ | |
view.animate() | |
.setDuration(DURATION_LIST) | |
.translationYBy(view.getHeight()) | |
.withEndAction(new Runnable() { | |
@Override | |
public void run() { | |
view.setVisibility(View.INVISIBLE); | |
view.setY(view.getY()-view.getHeight()); | |
} | |
}) | |
.start(); | |
} | |
} | |
public static void listEmerge(View... views) { | |
for(final View view: views){ | |
view.setY(view.getY()+view.getHeight()); | |
view.setVisibility(View.VISIBLE); | |
view.animate() | |
.setDuration(DURATION_LIST) | |
.translationYBy(-view.getHeight()) | |
.start(); | |
} | |
} | |
} | |
How To Use | |
AnimatorHelper.buttonEmerge(filterBtn, stickerBtn, takePictureBtn); | |
AnimatorHelper.listVanish(stickerRV); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment