Wir versuchen also, eine Animation zu erstellen, die den FAB bewegt, bevor er verschwindet und eine Symbolleiste öffnet. Das Problem ist, wenn ich die TranslationAnimation ausführe, verschwindet die FAB und schiebt sich dann vom Bildschirm weg. die von xDelta und von YDelta verhalten sich nicht so, wie ich sie auch erwarte.Die Translationsanimation beginnt nicht am Bildschirm, sondern am Bildschirm
Kann jemand darauf hinweisen, was ich falsch mache oder mir helfen zu verstehen, wie dieser Anruf funktioniert?
private void circularReveal(View toolbar, View fab) {
final View view1 = toolbar;
// get the center for the clipping circle
int cx = (toolbar.getLeft() + toolbar.getRight())/2;
int cy = (toolbar.getTop() + toolbar.getBottom())/2;
// get the final radius for the clipping circle
int finalRadius = Math.max(toolbar.getWidth(), toolbar.getHeight());
// create the animator for this view (the start radius is zero)
final SupportAnimator anim = ViewAnimationUtils.createCircularReveal(toolbar, cx, cy, 0, finalRadius);
//todo create an animation to move the fab.
TranslateAnimation translateAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f,
Animation.ABSOLUTE , -100f,
Animation.ABSOLUTE , 0f,
Animation.ABSOLUTE , -100f);
translateAnimation.setDuration(2000L);
translateAnimation.setFillAfter(true);
Animation.AnimationListener animationListener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view1.setVisibility(View.VISIBLE);
anim.start();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
};
translateAnimation.setAnimationListener(animationListener);
fab.startAnimation(translateAnimation);
}
EDIT reinigte ich im Code-Schnipsel einige Variablennamen auf.
Wie nennt man diese Methode? circularReveal (fab, toolbar); ? Weil Sie die translateAnimation in Ihrer Ansicht mit der benannten Symbolleiste anwenden. –
Die Methode wird vom OnClickListener aufgerufen, der in den Fragmenten onCreatView() auf dem Fab gesetzt wird. –