动画ActionBarDrawerToggle图标编程图标、动画、ActionBarDrawerToggle

由网友(伱的心,被莪扣押了)分享简介:我想从汉堡抽屉图标,动画一个箭头,反之亦然手动,不仅当抽屉被拖动,这可能吗?我使用的是支持库appcompat-V7:21。 I want to animate the drawer icon from a burger to an arrow and vice versa manually, not only wh...

我想从汉堡抽屉图标,动画一个箭头,反之亦然手动,不仅当抽屉被拖动,这可能吗?我使用的是支持库appcompat-V7:21。

I want to animate the drawer icon from a burger to an arrow and vice versa manually, not only when drawer is being dragged, is it possible? I'm using support library appcompat-v7:21.

另外,我找不到android.support.v7.app.ActionBarDrawerToggle源$ C ​​$ C这将有所帮助。

Also I can't find the source code of android.support.v7.app.ActionBarDrawerToggle which would helpful.

推荐答案

我找到了一种方法来制作具有简单ValueAnimator图标和 .onDrawerSlide 方法。

I found a way to animate the icon with a simple ValueAnimator and .onDrawerSlide method.

    ValueAnimator anim = ValueAnimator.ofFloat(start, end);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float slideOffset = (Float) valueAnimator.getAnimatedValue();
            drawerToggle.onDrawerSlide(drawerLayout, slideOffset);
        }
    });
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration(300);
    anim.start();

不过,也许有更好的解决方案。

But maybe there is a better solution.

阅读全文

相关推荐

最新文章