Remove App Icon from Navigation Drawer ActionBar Does not work

狂风中的少年 提交于 2019-12-03 23:07:01

问题


I am working on an App which has design requirement to be built as it should only have the Title on the ActionBar and not the App Icon. i tried various solutions found from StackOverflow like

getActionBar().setDisplayUseLogoEnabled(false);

    getActionBar().setDisplayShowHomeEnabled(false);

    getActionBar().setIcon(null);

however none of these worked so far, even i tried to make a hack/fix by making a transparent ic_launcher icon and put it into manifest.xml but it causes the App installation icon make transparent. please help

getActionBar().setDisplayShowHomeEnabled(false);

works perfectly in 4.4 kitkat , but showing a back arrow in downgraded version like this

and i need it like this to work in every device


回答1:


please try adding this..

    getActionBar().setDisplayHomeAsUpEnabled(true);

    getActionBar().setHomeButtonEnabled(true);

and in your theme add

<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>



回答2:


Its quite tricky anyhow, but i solved it,and it works like a charm in all devices.

I made a 2x2 px transparant icon and added it as

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

and removed the code

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

thanks to nDroidDev for suport



来源:https://stackoverflow.com/questions/27034564/remove-app-icon-from-navigation-drawer-actionbar-does-not-work

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