【问题标题】:Remove App Icon from Navigation Drawer ActionBar Does not work从导航抽屉操作栏中删除应用程序图标不起作用
【发布时间】:2014-11-20 08:03:23
【问题描述】:

我正在开发一个具有设计要求的应用程序,因为它应该只在 ActionBar 上有标题而不是应用程序图标。 我尝试了从 StackOverflow 中找到的各种解决方案,例如

getActionBar().setDisplayUseLogoEnabled(false);

    getActionBar().setDisplayShowHomeEnabled(false);

    getActionBar().setIcon(null);

但是到目前为止,这些都没有奏效,即使我试图通过制作一个透明的 ic_launcher 图标并将其放入 manifest.xml 来进行破解/修复,但这会导致应用程序安装图标变得透明。 请帮忙

getActionBar().setDisplayShowHomeEnabled(false);

在 4.4 kitkat 中完美运行,但在降级版本中显示后退箭头,如 this

我需要它在每个设备上都这样工作

【问题讨论】:

    标签: android android-actionbar navigation-drawer


    【解决方案1】:

    请尝试添加这个..

        getActionBar().setDisplayHomeAsUpEnabled(true);
    
        getActionBar().setHomeButtonEnabled(true);
    

    并在您的主题中添加

    <style name="CustomActionBarTheme"
           parent="@android:style/Theme.Holo.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/ActionBar</item
    </style>
    
    <!-- ActionBar styles -->
    <style name="ActionBar"
           parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
        <item name="android:icon">@android:color/transparent</item>
    
    
    </style>
    

    【讨论】:

    • getSupportActionBar().setHomeButtonEnabled(true);将使图标 ic_launcher 可见,我不希望 Drawer 图标已在 actionbarToggle 构造函数中指定
    • 我已经完成了你的回答但没有用,我使用的是透明主题 getActionBar().setHomeButtonEnabled(true);在我不需要的 ActionBar 中添加 ic_lancher
    【解决方案2】:

    无论如何,这很棘手,但我解决了它,它在所有设备上都像一个魅力。

    我制作了一个 2x2 像素的透明图标并将其添加为

    ActionBar actionBar = getActionBar();
    actionBar.setIcon(R.drawable.actionbar_null_icon);
    

    并删除了代码

    getActionBar().setDisplayUseLogoEnabled(false);
    getActionBar().setDisplayShowHomeEnabled(false);
    

    感谢 nDroidDev 的支持

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-20
      • 1970-01-01
      • 2014-09-14
      • 1970-01-01
      • 1970-01-01
      • 2016-04-27
      • 2013-06-06
      • 1970-01-01
      相关资源
      最近更新 更多