Search code examples
androideclipseandroid-actionbar-compatandroid-appcompat

After Updating the SDK API22 Not Showing App Icon, Action Bar Theme Color Changed as Default


I updated my SDK API 20 to API 22 in Eclipse.

After Updating My Sdk i Imported My Project from Other Workspace

Problem:

  1. Actionbar App icon Not Showing in My Application.

  2. I Already set theme Color in Themes.xml thats not Showing. it Changed as Default Black Colour.

Its Changed full structure of my App. Before Updating it works fine.

Please anyone Help me to Solve this.

manifest.xml

<application
        android:allowBackup="true"
        android:icon="@drawable/logo"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:theme="@style/CustomActionBarTheme" >


        <activity
            android:name="com.example.Start"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
 </application>

Themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- the theme applied to the application or activity -->
    <style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:actionBarTabStyle">@style/MyActionBarTabs</item>

        <!-- Support library compatibility -->

        <item name="android:actionBarTabTextStyle">@style/MyTheme.ActionBar.TabText</item>
         <item name="android:actionBarTabBarStyle">@style/Divider</item>
    </style>

<!-- for Tab divider -->
<style name="Divider" parent="@android:style/Widget.Holo.ActionBar.TabBar">
    <item name="android:divider">@android:color/transparent</item> //or use your transparent drawable image
    <item name="android:showDividers">middle</item>
    <item name="android:dividerPadding">0dp</item>
</style>

    <!-- ActionBar styles -->
    <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background">@color/easy</item>
        <!-- Support library compatibility -->
        <item name="background">@color/easy</item>
    </style>

    <style name="MyActionBarTabs" parent="@style/Widget.AppCompat.ActionBar.TabView">
        <item name="android:background">@drawable/actionbar_tab_indicator</item>
    </style>

    <style name="MyTheme.ActionBar.TabText" parent="android:style/Widget.Holo.ActionBar.TabText">

        <!-- This is a Black text color when selected and a WHITE color otherwise -->
        <item name="android:textColor">@color/selector_tab_text</item>
    </style>

</resources>

Solution

  • I had the same problem.

    To show icon use:

    getSupportActionBar().setIcon(R.drawable.ic_your_icon);
    

    in your activity onCreate()

    And for color add:

    <item name="colorPrimary">@color/your_color</item>
    

    to "CustomActionBarTheme" (not to "MyActionBar"!)

    And your theme should look like:

    <style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
            <item name="android:actionBarStyle">@style/MyActionBar</item>
            <item name="android:actionBarTabStyle">@style/MyActionBarTabs</item>
            <item name="colorPrimary">@color/your_color</item><!--put your color here-->
            <!-- Support library compatibility -->
    
            <item name="android:actionBarTabTextStyle">@style/MyTheme.ActionBar.TabText</item>
             <item name="android:actionBarTabBarStyle">@style/Divider</item>
        </style>
    

    And the other stuff in your theme.xml stays unchanged