工具栏导航汉堡图标丢失 [英] Toolbar Navigation Hamburger Icon missing
问题描述
我正在寻找一种方式来显示whitout使用抽屉/ DrawerToggle汉堡包图标,并使用包含在Android的默认图标
通过设置 getSupportActionBar()setDisplayHomeAsUpEnabled(真);
它显示后退箭头,但不是hambuerger。在#1其他职位(如这个或<一href="http://stackoverflow.com/questions/26754940/appcompatv7-v21-navigation-drawer-not-showing-hamburger-icon">this)使用DrawerLayout或自定义绘制,我找不到载体或png上的Android源汉堡包图标。
你知道我怎么能找到的android /支持库原汉堡图标?(或如何显示它)
注:Vector和PNG可以在google.com/design网站上找到:的<一个href="http://www.google.com/design/spec/resources/sticker-sheets-icons.html#">http://www.google.com/design/spec/resources/sticker-sheets-icons.html#
在我的活动
mToolbar =(工具栏)findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar()setDisplayHomeAsUpEnabled(真)。
getSupportActionBar()setHomeButtonEnabled(真)。
mToolbar.setNavigationOnClickListener(新View.OnClickListener(){
@覆盖
公共无效的onClick(视图v){
Log.d(LOG_TAG,导航点击);
}
});
布局文件
&LT; android.support.v7.widget.Toolbar
机器人:ID =@ + ID /工具栏
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =match_parent
机器人:=了minHeight?ATTR / actionBarSize
机器人:ATTR / colorPrimary后台=
应用程序:主题=@风格/ ThemeOverlay.AppCompat.ActionBar/&GT;
Styles.xml
&LT;! - 基本应用主题。 - &GT;
&LT;样式名称=Theme.AppTheme父=Theme.AppCompat.Light.NoActionBar&GT;
&LT;项目名称=colorPrimary&GT; @色/ primaryDef&LT; /项目&GT;
&LT;项目名称=colorPrimaryDark&GT; @色/ primaryDarkDef&LT; /项目&GT;
&LT;项目名称=colorAccent&GT; @色/ primaryDef&LT; /项目&GT;
&LT;! - 删除动作条的影子 - &GT;
&LT;项目名称=机器人:windowContentOverlay&GT; @空&LT; /项目&GT;
&LT; /风格&GT;
如果你想使用相同的抽屉的棒棒糖,然后让我告诉你,这不是一个静态图片。该图像是由一类名为 DrawerArrowDrawableToggle
绘制实时的。所以没有汉堡包的图标为该
不过,如果你想与没有动画的汉堡图标,你可以在这里找到它:
<一个href="http://shreyasachar.com/AndroidAssetStudio/icons-actionbar.html#source.type=clipart&source.space.trim=0&source.space.pad=0&source.clipart=res%2Fclipart%2Ficons%2Fmenu.svg&name=ic_action_menu&theme=light&color=000%2C54">http://shreyasachar.com/AndroidAssetStudio
您也可以使用<一个href="http://www.google.com/design/spec/resources/sticker-sheets-icons.html#sticker-sheets-icons-components">http://www.google.com/design/spec/resources/sticker-sheets-icons.html#sticker-sheets-icons-components并下载包。导航图标的名称为 ic_menu
,它位于第导航
文件夹:
<一个href="https://github.com/google/material-design-icons/blob/master/navigation/drawable-xxxhdpi/ic_menu_grey600_48dp.png">https://github.com/google/material-design-icons/blob/master/navigation/drawable-xxxhdpi/ic_menu_grey600_48dp.png
I'm looking for a way to display the hamburger icon whitout using the Drawer/DrawerToggle and use the default icon included in Android
By setting getSupportActionBar().setDisplayHomeAsUpEnabled(true);
it display the back arrow but not the hambuerger. Other post on Stackoverflow (like this or this) use the DrawerLayout or a custom drawable. I cannot find the vector or png for the hamburger icon on the Android source.
Do you know how can I find the original hamburger icon in android/support library? (or how to displayed it)
Note: Vector and png can be found on google.com/design website : http://www.google.com/design/spec/resources/sticker-sheets-icons.html#
In my activity
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(LOG_TAG, "navigation clicked");
}
});
Layout file
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.ActionBar"/>
Styles.xml
<!-- Base application theme. -->
<style name="Theme.AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primaryDef</item>
<item name="colorPrimaryDark">@color/primaryDarkDef</item>
<item name="colorAccent">@color/primaryDef</item>
<!-- Remove the actionbar shadow-->
<item name="android:windowContentOverlay">@null</item>
</style>
If you want to use the same drawer as lollipop then let me tell you that's not a static image. That image is drawn in real time by a class called DrawerArrowDrawableToggle
. So there is no "hamburger" icon for that.
However if you want the hamburger icon with no animation you can find it here:
http://shreyasachar.com/AndroidAssetStudio
You can also use http://www.google.com/design/spec/resources/sticker-sheets-icons.html#sticker-sheets-icons-components and download the pack. The navigation icon has the name ic_menu
and it's located on the navigation
folder:
这篇关于工具栏导航汉堡图标丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!