Hide app icon on navigation drawer home button

心不动则不痛 提交于 2019-12-14 03:16:05

问题


In my Nexus 5 (without physical buttons) it's alright, my action bar is as follow:

This is what I want for all devices.

Instead, in devices with physical buttons, this happens:

What should I do to force to show always the home button without the app icon?

The code used to setup the ActionBar in my Activity (in the onCreate() method) is:

private void setupActionBar() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.action_bar_layout);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
}

If I change:

actionBar.setDisplayShowHomeEnabled(false);

with:

actionBar.setDisplayShowHomeEnabled(true);

then I obtain that in all devices (both with or without physical buttons):

but I don't want the app icon near the icon with 3 lines!


回答1:


Set custom style for ActionBar like this:

<style name="ActionBar" parent="android:Widget.Holo.ActionBar">
    ...
    <item name="android:icon">@android:color/transparent</item> <!-- Hide logo from the action bar -->
</style>

thin set this style in application theme following way:

<item name="android:actionBarStyle">@style/ActionBar</item>

where:

<color name="transparent">#00000000</color>

Good luck!



来源:https://stackoverflow.com/questions/26323955/hide-app-icon-on-navigation-drawer-home-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!