1

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 thisenter image description here

and i need it like this to work in every device

enter image description here

Community
  • 1
  • 1
Bhavik Mehta
  • 573
  • 8
  • 21

2 Answers2

7

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>
iMDroid
  • 2,108
  • 1
  • 16
  • 29
  • getSupportActionBar().setHomeButtonEnabled(true); will make the icon ic_launcher visible which i dont want Drawer icon is already specified in actionbarToggle constructor – Bhavik Mehta Nov 20 '14 at 12:29
  • i have gone through your answer but didnt work, i am using a transparent theme getActionBar().setHomeButtonEnabled(true); adds ic_lancher in ActionBar which i dont need – Bhavik Mehta Nov 22 '14 at 09:06
5

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

Bhavik Mehta
  • 573
  • 8
  • 21