3

I am working with action bar and i want to customize the action bar logo. For that i have written code (below) but its working for Samsung and MicroMax devices but not for Lenovo K900 and Sony Ericssion Xperia z1. What should i do?

Api 16 its working fine but not in 17 (4.2)

Code:

 <style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
 </style>

 <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:logo">@drawable/product_category_logo</item>
    <item name="android:background">@drawable/actionbar_theme</item>
    <item name="android:backgroundStacked">@color/black</item>
    <item name="android:backgroundSplit">@color/white</item>
    <item name="android:textColor">#000000</item>
    <item name="android:textSize">16sp</item>
</style>

Values-v14 Folder:

<resources>

<!--
    Base application theme for API 14+. This theme completely replaces
    AppBaseTheme from BOTH res/values/styles.xml and
    res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!-- API 14 theme customizations can go here. -->
</style>

Values-v11 Folder:

<resources>

<!--
    Base application theme for API 11+. This theme completely replaces
    AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<!-- <style name="AppBaseTheme" parent="android:Theme.Holo.Light"> -->
    <style name="AppBaseTheme" parent="android:Theme.Light"><!-- Recent changes -->
    <!-- API 11 theme customizations can go here. -->
</style>

Guy i don't know what should i do. Please help me out.

user3154663
  • 291
  • 1
  • 2
  • 18

2 Answers2

1

I would suggest you to use ActionBarSherlock project in your application. Because this project already handles this kind of things for you.

And just for the sake of verification, Google is also using this ActionBar in its Google I/O app.

You can also download this project from GitHub ActionBarSherlock which also includes demo versions of this open source project.

To add ActionBarSherlock to your project:

Simply git clone the repo from GitHub in your workspace. And then import it as -> create project from existing source in Eclipse.

After this go to Project->Properties->Android and Add it as Library.

Here is your answer for importing it: Importing Actionbarsherlock into eclipse

And after importing it look for the Sample projects in it, how they are making use of Sherlock Action Bar. You will get a lot of info from there.

Most important thing about ActionBarSherlock is that you can also use it for Android OS below 3.0 but official Android API provide Action Bar widget only above OS v3.0. So you can target your app for all kind of users, those who are using OS above 3.0 and below 3.0, both will be targeted.

Community
  • 1
  • 1
Master
  • 2,945
  • 5
  • 34
  • 65
  • Simply git clone the repo from GitHub in your workspace. And then import it as -> create project from existing source in Eclipse. After this go to Project->Properties->Android and Add it as Library. – Master Feb 20 '14 at 08:47
  • my android:minSdkVersion="16" android:targetSdkVersion="19". tell me what should i do. – user3154663 Feb 20 '14 at 09:29
  • Follow this link: http://stackoverflow.com/questions/9757400/setting-actionbarsherlock-theme-for-android-app and try to customize your project like this. Also look for the SampleList's AndroidManifest.xml file and you will be able to run your project. – Master Feb 20 '14 at 09:32
0

Please add below theme in all folder - values,vaules-11values-14

<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
 </style>

 <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:logo">@drawable/product_category_logo</item>
    <item name="android:background">@drawable/actionbar_theme</item>
    <item name="android:backgroundStacked">@color/black</item>
    <item name="android:backgroundSplit">@color/white</item>
    <item name="android:textColor">#000000</item>
    <item name="android:textSize">16sp</item>
</style>

i think you have to use actionbarsharelock or actionbarcompart for < android 3.0

but first put this theme in values-11,values-14 and test the app.

also use theme MyActionBar in android manifest file.

try and let me k'no

Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177