그래서 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);
}
편집 나는 코드에 일부 변수 이름을 청소.
어떻게이 방법을 부릅니까? circularReveal (팹, 툴바); ? 왜냐하면 당신은 translateAnimation을 당신의 View라는 이름의 toolbar에 적용하기 때문입니다. –
메서드는 에서 호출되며, onClickListener는 onCreatView()의 조각에서 Fab에 설정됩니다. –