I've been recently developing an Android app, in which i need to have a custom layout and dimension for the tab bar. The way that i did it until now is by using Jake Wharton's ActionBarSherlock library to support pre-HoneyComb Android versions, and by applying a style to the app in which i edit the actionBarSize style item.
Now, I've been testing the app on the Galaxy S3 (with Jellybean on it), and the tab bar height doesn't change anymore according to the actionBarSize
value.
So I've started looking through JellyBean's code, and I found this method in the ActionBarPolicy
class:
public int getTabContainerHeight() { TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar, com.android.internal.R.attr.actionBarStyle, 0); int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0); Resources r = mContext.getResources(); if (!hasEmbeddedTabs()) { // Stacked tabs; limit the height height = Math.min(height, r.getDimensionPixelSize(R.dimen.action_bar_stacked_max_height)); } a.recycle(); return height; }
From what i gather in this method, it seems that JellyBean limits the height of the TabBar, when the app is in portrait mode, by setting the tab bar height to the "action_bar_stacked_max_height" dimension value (which is 48dp, in 4.1's /values/dimen.xml
file), even though I've set the action bar height in actionBarSize
.
I've tried overriding this dimension value, by setting it to my own value in my own dimen.xml
file, but i had no luck. It didn't work.
My question:
Do you guys know of a way in which i can override the"action_bar_stacked_max_height" dimen value?
Thank you in advance!
This example demonstrates how to change action bar size in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 3 − Add the following code to res/layout/activity_main. xml.
Try putting android:actionBarSize
and actionBarSize
under the Theme you are using, like so:
<style name="Theme.white_style" parent="@android:style/Theme.Holo.Light.DarkActionBar"> <item name="android:actionBarSize">55dp</item> <item name="actionBarSize">55dp</item> </style>
Try using android:height
like the following:
<style name="AppActionBar"> <item name="android:height">50dp</item> </style> <style name="MainActivityStyle" parent="@android:style/Theme.Holo"> <item name="android:actionBarStyle">@style/AppActionBar</item> </style>
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