Hello.
There are multiple screens using the viewpager, and the toolbar is using one for public use. If you move the screen here, the toolbar button is shown below to match the screen.
ObjectAnimator animRightX = ObjectAnimator.ofFloat(view, "scaleX", 0);
If you move the screen, the animation works well when it disappears, but if you turn it to the original screen, the scaleX should be zero, but it disappeared because it was one again A replay double animation is executed.
Display screen 1 button
↓
Screen 2 button disappears into scale animation (log scale 0)
↓
Screen 1 button has a scale of 1... Before re-displaying animation starts (log scale 1)
If there is nothing on screen 2, the scale remains zero... If you are displaying a list or view on screen 2, scale 0 cannot be maintained.
I'm sorry you're busy, but if you have any hints, I'll happily refer to them.
android
Activity = Toolbar
↓
Page View
↓
Fragment 1, Fragment 2, Fragment 3
If you move the page view here, in the Toolbar class at the time of pressing Viewpager select Page in the activity,
final ObjectAnimator animRightX = ObjectAnimator.ofFloat(view, "scaleX", isShow ? 1f : 0f);
final ObjectAnimator animRightY = ObjectAnimator.ofFloat(view, "scaleY", isShow ? 1f : 0f);
final AnimatorSet animSetRightXY = new AnimatorSet();
animSetRightXY.playTogether(animRightX, animRightY);
animSetRightXY.start();
That's what I'm doing
Listener is
animSetRightXY.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
if ((isShow && view.getScaleX() == 0)) {
view.setVisibility(View.VISIBLE);
}
}
@Override
public void onAnimationEnd(Animator animation) {
if ((isShow && view.getScaleX() == 1.0)) {
view.setVisibility(View.VISIBLE);
} } else if ((!isShow && view.getScaleX() == 0)) {
view.setVisibility(View.INVISIBLE);
}
view.clearAnimation();
view.animate().setListener(null);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
© 2024 OneMinuteCode. All rights reserved.