简体   繁体   English

Android汉堡包图标是4.x上的箭头

[英]Android Hamburger icon is an arrow on 4.x

I've implemented the ActionBarDrawerToggle with the hamburger icon (support library v7), but for some reason the toggle only displays a 'back' arrow on devices not running 5.0 (I have confirmed this for all 4.x versions). 我已经使用汉堡包图标(支持库v7)实现了ActionBarDrawerToggle,但由于某种原因,切换仅在未运行5.0的设备上显示“后退”箭头(我已经为所有4.x版本确认了这一点)。 Is this normal behaviour? 这是正常的行为吗?

The arrow looks like this: 箭头看起来像这样:

箭头

Now the arrow icon doesn't change. 现在箭头图标不会改变。 It's the same when the navigation drawer is pulled out, or when it is in collapsed mode. 拉出导航抽屉或处于折叠模式时也是如此。

This is how I initalize the drawertoggle etc. 这就是我对drawertoggle等的初衷。

// drawer toggle
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
        R.string.drawer_open, R.string.drawer_close);
mDrawerLayout.setDrawerListener(mDrawerToggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);

EDIT 编辑

For some clarification. 有些澄清。 I am using the old regular ActionBar, not the Toolbar. 我使用旧的常规ActionBar,而不是工具栏。 The hamburger icon DOES show on 5.0 devices but not on < 5.0. 汉堡图标显示在5.0设备上但不在<5.0上。 Should I use the toolbar to fix this problem? 我应该使用工具栏来解决这个问题吗?

In order to get the hamburger icon this piece of code below is enough 为了获得汉堡包图标,下面这段代码就足够了

Toolbar toolbar =(Toolbar)findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

it's showing back button because you are using the method setDisplayHomeAsUpEnabled(true); 它正在显示后退按钮,因为您正在使用方法setDisplayHomeAsUpEnabled(true);

Check out the official reference Click here 查看官方参考点击此处

我只是复制drawable并重命名它,如果你想在所有设备上使用它,请使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM