Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionbar Title Disappears When Given Style

I have been adding style to my Actionbar and everythings been working well, until I try to change the Actionbar title. When I add style to the Actionbar's title the title just disappears. The Actionbar is still there, but there is simply no title.

This is my Actionbar style code

<style name="Theme.TabTheme" parent="Theme.AppCompat">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/dark_primary</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowActionBar">true</item>
    <item name="android:actionBarStyle">@style/Theme.TabTheme.MyActionBar</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTabs</item>
</style>

<style name="Theme.TabTheme.MyActionBar" parent="ThemeOverlay.AppCompat.ActionBar">
    <item name="android:background">@color/primary</item>
    <item name="android:height">50dp</item>
    <item name="android:titleTextStyle">
        @style/Theme.TabTheme.MyActionBar.TitleTextStyle
    </item>
</style>

<style name="Theme.TabTheme.MyActionBar.TitleTextStyle"
       parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
    <item name="android:textColor">@color/primary_text</item>
    <item name="android:text">@string/app_name</item>
    <item name="android:textSize">15sp</item>
</style>

<!-- ActionBar tabs styles -->
<style name="MyActionBarTabs" parent="Theme.AppCompat">
    <!-- tab indicator -->
    <item name="android:background">@drawable/actionbar_tab_indicator</item>
</style>

Why is adding style to the Actionbar Title making the title disappear?

like image 847
Gary Holiday Avatar asked Apr 30 '15 00:04

Gary Holiday


1 Answers

Try adding displayOptions like this to your Action Bar style:

<item name="android:displayOptions">showHome|useLogo|showTitle</item>

or

<item name="displayOptions">showHome|useLogo|showTitle</item>
like image 126
Virat Singh Avatar answered Sep 24 '22 23:09

Virat Singh