FABを消す前にFABを移動し、ツールバーを開くアニメーションを作成しようとしています。問題は、TranslationAnimationを実行してFABが消えた後、画面外にスライドするときです。 fromxDeltaとfromDeltaは、私がそれらを期待する方法を実行することはありません。翻訳アニメーションは、所属する場所ではなく画面から開始します
私が間違っていることを指摘したり、この呼び出しの仕組みを理解するのに役立ちますか?
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私は、コードスニペットでは、いくつかの変数名をクリーンアップ。
どうやってこのメソッドを呼び出しますか? circularReveal(ファブ、ツールバー); ?これは、名前付きのツールバーであるビューにtranslateAnimationを適用するためです。 –
このメソッドは、フラグメントonCreatView()でFabに設定されているonClickListenerの から呼び出されます。 –