【问题标题】:FloatingButton to Toolbar animation浮动按钮到工具栏动画
【发布时间】:2015-04-19 05:40:11
【问题描述】:

我在我的应用程序上使用了一个浮动按钮,但我想转换为工具栏,就像在视频上显示一样,有人有一个示例吗?如果没有,请不要担心我开始开发,但我想要一个指导,谢谢

我有这个选项:

ViewCompat.animate(view).setDuration(1000).scaleYBy(1).scaleXBy(1).start();

或者这个选项:

 ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, transitionView, EXTRA_IMAGE);

sample video

【问题讨论】:

    标签: android user-interface animation material-design


    【解决方案1】:

    我创建了解决方案,我没有相同的结果,但对我有用,我发布了我的代码:

    private void animateBottomToolbar() {
        AnimatorSet set = new AnimatorSet().setDuration(500L);
        if(bottomToolbarShowing) {
            //hide toolbar
            set.playTogether(
                    ObjectAnimator.ofFloat(toolbarBottom, "scaleY", 1.0f, 0.0f),
                    ObjectAnimator.ofFloat(addButton, "scaleY", 0.0f, 1.0f)
            );
    
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationStart(animation);
                    addButton.setVisibility(View.VISIBLE);
                    toolbarBottom.setVisibility(View.GONE);
                    animation.removeAllListeners();
                }
            });
    
            set.setInterpolator(new OvershootInterpolator());
            set.start();
            bottomToolbarShowing = false;
        } else {
            //show toolbar
            if (floatMenuOpen) animateFloatingMenu();
            set.playTogether(
                    ObjectAnimator.ofFloat(toolbarBottom, "scaleY", 0.0f, 1.0f),
                    ObjectAnimator.ofFloat(addButton, "scaleY", 1.0f, 0.0f)
            );
    
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    addButton.setVisibility(View.GONE);
                    toolbarBottom.setVisibility(View.VISIBLE);
                    animation.removeAllListeners();
                    inflateMenuOnBottomToolbar();
                }
            });
            set.setInterpolator(new OvershootInterpolator());
            set.start();
            bottomToolbarShowing = true;
        }
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-11-25
      • 2012-11-23
      • 2015-03-11
      • 2012-07-30
      • 2015-07-21
      • 2016-04-29
      • 1970-01-01
      相关资源
      最近更新 更多