user3008777
user3008777

Reputation: 1441

Actionbar title is not appearing

I am using AppCompat Library. in values/styles.xml I am using the following code

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">

    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:actionBarStyle" tools:ignore="NewApi">@style/CLActionBar</item>
    <item name="actionBarStyle">@style/CLActionBar</item>
</style>

<!-- ActionBar styles -->
<style name="CLActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background" tools:ignore="NewApi">@color/actionbar_bg_color</item>
    <item name="android:textColor" tools:ignore="NewApi">@color/actionbar_txt_color</item>
    <item name="android:subtitleTextStyle" tools:ignore="NewApi">@style/MyTheme.ActionBar.TitleTextStyle</item>

    <item name="background" >@color/actionbar_bg_color</item>
    <!--<item name="textColor" >@color/actionbar_txt_color</item>-->
    <item name="subtitleTextStyle" >@style/MyTheme.ActionBar.TitleTextStyle</item>

</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
    <item name="android:textColor" tools:ignore="NewApi">@color/actionbar_txt_color</item>
    <!--<item name="textColor">@color/actionbar_txt_color</item>-->
</style>

in values-v21/styles.xml

&lt;!&ndash; Base application theme. &ndash;&gt;
<style name="AppTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">
    &lt;!&ndash; Customize your theme here. &ndash;&gt;
</style>

-->

    <item name="android:actionBarStyle" tools:ignore="NewApi">@style/CLActionBar</item>
    <item name="actionBarStyle">@style/CLActionBar</item>
    </style>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light">
    <!--<item name="android:windowContentTransitions">true</item>-->
    <!--<item name="android:windowAllowEnterTransitionOverlap">true</item>-->
    <!--<item name="android:windowAllowReturnTransitionOverlap">true</item>-->
    <!--<item name="android:windowSharedElementEnterTransition">@android:transition/move</item>-->
    <!--<item name="android:windowSharedElementExitTransition">@android:transition/move</item>-->
</style>

<!-- ActionBar styles -->
<style name="CLActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
    <item name="android:background" tools:ignore="NewApi">@color/actionbar_bg_color</item>
    <item name="android:textColor" tools:ignore="NewApi">@color/actionbar_txt_color</item>
    <item name="android:subtitleTextStyle" tools:ignore="NewApi">@style/MyTheme.ActionBar.TitleTextStyle</item>

    <item name="background" >@color/actionbar_bg_color</item>
    <!--<item name="textColor" >@color/actionbar_txt_color</item>-->
    <item name="subtitleTextStyle" >@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
    <item name="android:textColor" tools:ignore="NewApi">@color/actionbar_txt_color</item>
    <!--<item name="textColor">@color/actionbar_txt_color</item>-->
</style>

now when i try to set title to actionbar using getSupportActionBar.setTitle the title does not appear. Please help

Upvotes: 0

Views: 2471

Answers (2)

user3008777
user3008777

Reputation: 1441

I solved the issue I was using Theme.AppCompat.Light as app theme and @android:style/Widget.Holo.Light.ActionBar.Solid.Inverse" as actionbar theme. Changed this to @style/Widget.AppCompat.Light.ActionBar.Solid.Inverse and the issue is fixed. Thanks

Upvotes: 2

Jai Rajesh
Jai Rajesh

Reputation: 949

paste the below lines in value folder

<style name="MYBaseTheame" parent="@style/Theme.AppCompat.Light">
    <item name="actionBarStyle">@style/Widget.MYTheame.ActionBar</item>
</style>

<style name="MYTheame" parent="@style/MYBaseTheame">
    <item name="android:windowBackground">@color/app_bg</item>
    <item name="android:tabWidgetStyle">@android:style/Widget.TabWidget</item>
</style>

<style name="MYTheame.NoTittle" parent="@style/MYTheame">
    <item name="android:windowNoTitle">true</item>
</style>

<style name="Widget.MYTheame.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="titleTextStyle">@style/TextAppearance.MYTheame.Widget.ActionBar.Title</item>
    <item name="background">@color/ab_bg</item>
</style>

And Paste the below lines to value-14 folder

<style name="MYBaseTheame" parent="@style/Theme.AppCompat.Light">
    <item name="android:actionBarStyle">@style/Widget.MYTheame.ActionBar</item>
</style>

<style name="Widget.MYTheame.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="android:titleTextStyle">@style/TextAppearance.MYTheame.Widget.ActionBar.Title</item>
    <item name="android:background">@color/ab_bg</item>
</style>

Upvotes: 0

Related Questions