Search code examples
androidandroid-actionbaractionbarsherlock

Issue while displaying action bar with title in android 4.0 or higher


i am using action bar in my app.i used sherlock library to display action bar below android version 3.0.it's working fine.I want to add title bar into my app.i did the following:

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title_layout);

And in xml i did this :

<style name="title_theme" parent="@style/Sherlock.__Theme.DarkActionBar">
        <item name="android:windowNoTitle">false</item>
        <item name="android:windowTitleSize">50dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/title_theme</item>
    </style>

it worked on Android api < 3.0, but above 3.0 it doesn't work.it says:

You cannot combine custom titles with other title feature..

Solution

  • may be there is no need to use title bar because action bar supports title feature
    So you have to add just
    getSherlockActivity.getSupportActionBar().setTitle("some text");
    have you tried this

    getSherlockActivity.getSupportActionBar().setCustomView(customNav); getSherlockActivity.getSupportActionBar().setDisplayShowCustomEnabled(true);