隐藏的抽屉式导航栏主页按钮的应用程序图标应用程序、图标、按钮、抽屉式

2023-09-12 03:26:42 作者:男人的许诺丶都是浮云

在我的Nexus 5(无实体按键),这是正常的,我的操作栏是如下:

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

这就是我想要的所有设备。

相反,与物理按键的设备,出现这种情况:

Instead, in devices with physical buttons, this happens:

我应该怎么做来强制始终显示主页按钮没有应用程序图标

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

用于设置动作条在我的活动(在OnCreate()方法)的code是:

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);
}

如果我更改:

actionBar.setDisplayShowHomeEnabled(false);

actionBar.setDisplayShowHomeEnabled(true);

然后我得到了所有设备(无论有或没有物理按键):

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

但我不希望有3条线路附近的图标的应用程序图标!

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

推荐答案

设置自定义样式动作条是这样的:

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>

其中:

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

祝你好运!