Created
January 24, 2024 08:43
-
-
Save yccheok/02b215b6243bfb1d58dc531d89aea9e8 to your computer and use it in GitHub Desktop.
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 static void expandAnimation(View view) { | |
int config_shortAnimTime = WeNoteApplication.instance().getResources().getInteger(android.R.integer.config_shortAnimTime); | |
int prevHeight = view.getHeight(); | |
// TODO: | |
int targetHeight = dpToPixel(120); | |
ValueAnimator valueAnimator = ValueAnimator.ofInt(prevHeight, targetHeight); | |
valueAnimator.setInterpolator(new AccelerateInterpolator()); | |
valueAnimator.setDuration(config_shortAnimTime); | |
valueAnimator.addUpdateListener(animation -> { | |
view.getLayoutParams().height = (int) animation.getAnimatedValue(); | |
view.requestLayout(); | |
}); | |
valueAnimator.addListener(new AnimatorListenerAdapter() { | |
@Override | |
public void onAnimationEnd(Animator animation) | |
{ | |
view.getLayoutParams().height = targetHeight; | |
view.requestLayout(); | |
} | |
}); | |
view.setVisibility(View.VISIBLE); | |
valueAnimator.start(); | |
} | |
public static void collapseAnimation(View view) { | |
int config_shortAnimTime = WeNoteApplication.instance().getResources().getInteger(android.R.integer.config_shortAnimTime); | |
int prevHeight = view.getHeight(); | |
int targetHeight = 0; | |
ValueAnimator valueAnimator = ValueAnimator.ofInt(prevHeight, targetHeight); | |
valueAnimator.setInterpolator(new AccelerateInterpolator()); | |
valueAnimator.setDuration(config_shortAnimTime); | |
valueAnimator.addUpdateListener(animation -> { | |
view.getLayoutParams().height = (int) animation.getAnimatedValue(); | |
view.requestLayout(); | |
}); | |
valueAnimator.addListener(new AnimatorListenerAdapter() { | |
@Override | |
public void onAnimationEnd(Animator animation) | |
{ | |
view.setVisibility(View.GONE); | |
} | |
}); | |
valueAnimator.start(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment