So I'm trying to style the tabs of my Actionbar, which I've implemented using the ActionBarSherlock library. This is my code:
<style name="Theme.AndroidDevelopers" parent="Theme.Sherlock.Light.ForceOverflow">
<item name="actionBarTabStyle">#style/CustomActionBarStyle</item>
<item name="android:actionBarTabStyle">#style/CustomActionBarStyle</item>
<style name="CustomActionBarStyle" parent="Widget.Sherlock.Light.ActionBar.TabBar">
<item name="android:background">#drawable/actionbar_tab_bg</item>
</style>
At the second and third line, if I change actionBarTabStyle to actionBarStyle, my actionbar itself is changed to my wanted style (not very well, ofcourse), so the connections do work. However, trying to change the actionbar tabs (below it), has still no success.
I hope somebody can help me.
With Regards,
The following should work
<style name="Theme.app" parent="#style/Theme.Sherlock.Light">
<item name="android:actionBarTabBarStyle">#style/Theme.app.tabbar.style</item>
<item name="actionBarTabBarStyle">#style/Widget.app.ActionBar.TabBar</item>
</style>
<style name="Theme.app.tabbar.style" parent="#style/Theme.Sherlock.Light">
<item name="android:background">#FF0000</item>
<item name="background">#FF0000</item>
</style>
<style name="Widget.app.ActionBar.TabBar" parent="Widget.Sherlock.ActionBar.TabBar">
<item name="android:background">#FF0000</item>
<item name="background">#FF0000</item>
</style>
This makes the tabBar red.
You need to set two times the actionBarTabBarStyle. This is because of Android > 3.0 and Android <3.0
In your CustomActionBarStyle you need to have
<item name="android:background">#drawable/actionbar_tab_bg</item>
<item name="background">#drawable/actionbar_tab_bg</item>
Hope this helps :)
So I had some difficulties with the styling because of a certain way I found to add the tabs by code in the first place. Thank you for the responses, they all work.
Related
I want to remove the divider under the ActionBar, already search here for it and tried the different things, but nothing worked for me.
Here are the styles, I hope you can help me.
<style name="ListeningThemeTranslucentActionBar" parent="#style/ListeningTheme">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">#style/ListeningTranslucentActionBar</item>
<item name="android:actionBarDivider">#null</item>
</style>
<style name="ListeningTranslucentActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#android:color/transparent</item>
</style>
You probably didn't apply your styles in the Manifest. You will have to add
android:theme="#style/ListeningThemeTranslucentActionBar"
in your Manifest.xml. (If there is already a android:theme parameter just change it to your theme.)
Also this link might be helpfull.
I have been trying to change the background of my action bar for quite some time now. I found some posts here of users who could change the background but not the text color. In my example this is the contrary as the background is giving me problems.
I have not created any dynamic design from my activity.
The following is my style.xml:
<style name="MyTheme" parent="android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyTheme.ActionBarStyle</item>
</style>
<style name="MyTheme.ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="android:background">#FD5200</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#FD5200</item>
</style>
Any knows what might be causing this?
Consider using ActionBarSherlock a link here may help you going.
I am using ActionBarSherlock 4.0.2.
I need a fully transparent action bar (without the neon color bottom divider). Hence, I have the following style:
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="windowActionBarOverlay">true</item>
<item name="icon">#drawable/ic_home</item>
<item name="titleTextStyle">#style/ActionBarCompatTitle</item>
<item name="android:windowFullscreen">true</item>
</style>
By using above code, I will still have the following effect.
In order to disable the background, I put the following code in SherlockFragmentActivity#onCreate. Then the problem gone.
getSupportActionBar().setBackgroundDrawable(null);
However, I would like to see the solution being implemented in styles.xml instead of Java code, as I have many other devices with different screen configuration. I modified the styles.xml to the following, without using the previously mentioned fix in the Java code.
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="windowActionBarOverlay">true</item>
<item name="icon">#drawable/ic_home</item>
<item name="titleTextStyle">#style/ActionBarCompatTitle</item>
<item name="android:windowFullscreen">true</item>
<item name="android:background">#drawable/transparent</item>
<item name="background">#drawable/transparent</item>
</style>
However, the neon divider still visible. It seems that my fix using android:background and background does not work. Am I missing something?
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="#style/Widget.Sherlock.ActionBar">
<item name="background">#android:color/transparent</item>
<item name="android:background">#android:color/transparent</item>
</style>
I am trying to apply default styling for all the listViews from style.xml
Please note at some places I am using nested listViews.
In style.xml
<style name="Theme.MyTheme" parent="Theme.Sherlock.Light.ForceOverflow">
<item name="android:windowContentOverlay">#null</item>
<item name="android:listViewStyle">#style/awesomeListViewStyle</item>
</style>
<style name="awesomeListViewStyle" parent="#android:style/Widget.ListView">
<item name="android:fadingEdge">none</item>
<item name="android:background">#color/orange</item>
<item name="android:divider">#EEEEEE</item>
</style>
This has no effect. In the Manifest Theme.MyTheme as my default theme.
Please advice :)
As mentioned in another answer as Bhavin and Mark pointed out, in your style you should also add
<item name="android:dividerHeight">1px</item>
Many of my questions about "styling" actionbar tabs were answered by adamp in this thread on tab style, but I am still struggling with my arriving at the desired presentation.
Specifically, I am attempting to do what adamp suggested in the following fragment from my styles.xml file, but, I cannot get the inherited (Widget.holo.actionbar) feature of a light blue line to appear under the selected tab nor is there any indication of selection:
<style name="MyTheme" parent="android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/CustomActionBar</item>
</style>
<style name="CustomActionBar" parent="android:style/Widget.Holo.ActionBar">
<item name="android:actionBarTabTextStyle">#style/customActionBarTabTextStyle</item>
<item name="android:actionBarTabStyle">#style/customActionBarTabStyle</item>
<item name="android:actionBarTabBarStyle">#style/customActionBarTabBarStyle</item>
</style>
<style name="customActionBarTabTextStyle" parent="#style/CustomActionBar">
<item name="android:textColor">#2966c2</item>
<item name="android:textSize">20sp</item>
<item name="android:typeface">sans</item>
</style>
<style name="customActionBarTabStyle" parent="#style/CustomActionBar">
<!-- <item name="android:background">#drawable/actionbar_tab_bg</item> -->
<item name="android:paddingLeft">20dp</item>
<item name="android:paddingRight">20dp</item>
</style>
<style name="customActionBarTabBarStyle" parent="#style/CustomActionBar">
<item name="android:paddingLeft">240dp</item>
</style>
Can someone explain why the thin blue line selection behavior of the Honeycomb Gallery Sample App does not work for me?
New insight since this was written: the problem here, I think, is that the style I have created to overide ActionBarTabStyle is entirely bogus:
<style name="customActionBarTabStyle" parent="#style/CustomActionBar">
<item name="android:paddingLeft">20dp</item>
<item name="android:paddingRight">20dp</item>
</style>
I need to specify the correct parent of this style per "Theme.holo"....how can one find where the default style is so it can be specified as a parent?
Thanks
To specify the correct parents for actionbar style in API 11, Check doc here:
https://developer.android.com/training/basics/actionbar/styling.html