在使用设计支持库时如何为汉堡图标设置后箭头动画效果? [英] How to animate the hamburger icon to back arrow while using design support library?

查看:87
本文介绍了在使用设计支持库时如何为汉堡图标设置后箭头动画效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在使用android中最新的支持库(称为设计支持库),并在其中使用NavigationView来拖动抽屉.但是问题是当我打开抽屉时,我的汉堡图标不会旋转为后退箭头图标,它始终保持不变,但是我可以记住,当我使用不带支持库的抽屉布局时,它会自动旋转,这是我的最后一次尝试我做到了:

Hello I am using the most recent support library from android called design support library and using the NavigationView in it for shwing drawer. But the problem is when I am openning my drawer my hamburger icon doesnt spins into a back arrow icon, it always remains the same, but I can remember that when I used the drawerlayout without the support library it spinned automatically, here is my last try that I did:

dl.setDrawerListener(new ActionBarDrawerToggle(this, dl, tb, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);

                supportInvalidateOptionsMenu();
            }

            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
                supportInvalidateOptionsMenu();
            }

            @Override
            public void onDrawerSlide(View drawerView, float slideOffset) {
                super.onDrawerSlide(drawerView, slideOffset);

            }
        });

但没有什么障碍,我在这里有什么误区吗?

but nothing happeded, is there any short trick or tips that I am mising here?

推荐答案

我已经解决了我的问题,实际上,我正在使用一种使用以下代码将汉堡包图标设置为操作栏图标的方法:

I have solved my problem by this, Actually I was using a method to hard set the hamburger icon as the actionbar icon using this code:

ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);

我刚刚注释掉了这一行代码,然后它起作用了.

I have just commented out this line of code and then it worked.

这篇关于在使用设计支持库时如何为汉堡图标设置后箭头动画效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆