Android hamburger menu button shake animation

时间:2017-07-17 15:31:07

标签: android animation

I need to create an animation to periodically make the hamburger menu button shake. If this were just a view I could figure it out but it isn't. Here's how I'm setting up the icon with a custom image:

final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

toolbar.post(new Runnable() {
    @Override
    public void run() {
        Drawable d = ResourcesCompat.getDrawable(getResources(), R.drawable.ham_menu, null);
        toolbar.setNavigationIcon(d);
    }
});

I can't just animate the toolbar (which is a View where I could set an animation), I need to animate just the menu icon. Searching for an answer is not working because all the results are about the animation between the icon and the arrow when the drawer opens and closes. Is this even possible?

1 个答案:

答案 0 :(得分:0)

我通过来回切换可绘制来解决这个问题,但是如果有人有更好的解决方案,那就太好了。

.travis.yml