Does anyone know the style resource to use for the split action bar when using sdk version 14 android:uiOptions="splitActionBarWhenNarrow"
?
For the normal ActionBar
I can use
<item name="android:actionBarStyle">@style/MyActionBar</item>
But this does not automatically overflow to the split bar at the bottom.
I have tried
<item name="android:actionBarSplitStyle">@style/MyActionBar</item>
<item name="android:actionBarTabBarStyle">@style/MyActionBar</item>
But they both have no effect on the Galaxy Nexus
This question is old, but i've just handled the same problem. If it can help someone else...
The split bar is also styled using ActionBarStyle.
For example, if you want to style the bottom part of the split action bar, you can use the item named backgroundSplit in your MyActionBar style.
...
<item name="android:actionBarStyle">@style/MyActionBar</item>
...
<style name="MyActionBar">
<item name="background">@drawable/action_bar_top_background</item>
<item name="backgroundSplit">@drawable/action_bar_bottom_background</item>
</style>
you can use a style instead of the drawable to customize the backgrounds, but if prefer this to define backgrounds in drawables.
This answer is basically niko34's but in a little bit more detail. Currently I have both the top actionbar and the lower actionbar (the lower actionbar is more properly named as the split actionbar) styled the same, but you'll see it's pretty darn simple to style them differently. I am using ActionBarSherlock v4.2.0, and have tested and run this flawlessly on both a Samsung Galaxy S3 running Jelly Bean and an HTC Droid Incredible running Gingerbread.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="..."
android:versionCode="1"
android:versionName="0.1" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="16" />
<application
android:icon="@drawable/launcher"
android:label="@string/app_name" >
<activity
android:label="@string/main_activity_title"
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.Styled"
android:uiOptions="splitActionBarWhenNarrow" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/bg_actionbar</item>
<item name="android:background">@drawable/bg_actionbar</item>
<item name="backgroundSplit">@drawable/bg_actionbar</item>
<item name="android:backgroundSplit">@drawable/bg_actionbar</item>
</style>
</resources>
Here you can see how I'm referencing @drawable/bg_actionbar
a couple of times. That is an xml file that is located in the res/drawable
directory. Below is the source of that file.
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/bg_tile"
android:tileMode="repeat" />
Here, android:src="@drawable/bg_tile"
is just referencing my bg_tile.png
file, which is located in res/drawable-hdpi
, res/drawable-ldpi
, res/drawable-mdpi
, and res/drawable-xhdpi
.
So all of this was probably more information than necessary, but it's better than not having enough! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With