Droidman
Droidman

Reputation: 11608

android - ActionBar custom View without icon

In my application a have an ActionBar with Tabs as navigation mode. I also use a custom View which adds another "line" to the ActionBar. Setup looks like:

    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.ab);
    Typeface font = Typeface.createFromAsset(getAssets(), "cs_regular.ttf");
    TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.tvActionTitle);
    title.setTypeface(font);

The problem: I do not want an icon to be shown, but when I use actionBar.setDisplayShowHomeEnabled(false); my custom layout gets placed BELOW the Tabs and I need it to be above the Tabs in the ActionBar. Setting it to true places the layout as I need it, but shows the unnecessary icon.. any suggestions?

Upvotes: 0

Views: 745

Answers (1)

Xaver Kapeller
Xaver Kapeller

Reputation: 49817

I assume by icon you mean the app icon. You can essentially make it invisible using styles. Add this to the style your Activity is using:

<item name="android:icon">@android:color/transparent</item>

Upvotes: 2

Related Questions