Итак, мы пытаемся сделать анимацию, которая перемещает FAB до ее исчезновения и открывает панель инструментов. Проблема в том, что когда я запускаю TranslationAnimation, FAB исчезает, а затем переходит с экрана. fromxDelta и fromYDelta никогда не ведут себя так, как я их ожидаю.Перевод анимации начинается с экрана вместо того, где он принадлежит
Может ли кто-нибудь указать, что я делаю неправильно, или помочь мне понять, как работает этот звонок?
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 Я очистил некоторые имена переменных в фрагменте кода.
как вы называете этот метод? roundReveal (fab, панель инструментов); ? Потому что вы применяете translateAnimation в своем представлении, который называется панелью инструментов. –
Метод вызывается из onClickListener, который устанавливается на Fab в фрагментах onCreatView(). –