I have been working with the ActionBar and ActionBarSherlock for the last few days, and i am having some issues when filling some information in the ActionBar.
When the application runs in portrait mode, the ActionBar looks fine, and all the data can be displayed, for example:
But when i switch the app to be displayed in landscape, some of the data is cropped:
You can notice how both the status icon and the email has been cropped due to the new height of the ActionBar.
In this case, i want to keep the same size for portrait and landscape so the app can look fine. I can't reduce the font size of the action bar title, since it may include other icons.
The way i´m putting these icons in the action bar title and subtitle is by using Html.fromHtml
Any ideas to solve this problem? I am using the ActionBarSherlock library!
One, probably not too pretty approach, could be to override the default height values for the ActionBar in dimens.xml
.
E.g. the default value in portrait is:
<dimen name="abs__action_bar_default_height">48dip</dimen>
And in landscape:
<dimen name="abs__action_bar_default_height">40dip</dimen>
There might be a cleaner way to do it, but I have to admit I know too little about the internals of ActionBarSherlock for that.
Edit: Come to think of it, this probably won't work when the native ActionBar is being used on ICS, since the height will then resolve to the platform value in ?android:attr/actionBarSize
. I'd recommend you wait for a better suggestion, e.g. from Jake himself.
Second edit:
After Jake's reply it seems like all you need to do to make it work with ActionBarSherlock on both ICS and pre-ICS devices is add the following to your app's theme:
<item name="actionBarSize">@dimen/some_value</item>
<item name="android:actionBarSize">@dimen/some_value</item>
You can then add the actual values in the relevant portrait/land resource buckets.
Third edit [thanks alvarolb]: XML Example for the style:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarSize">48dip</item>
<item name="android:actionBarSize">48dip</item>
</style>
</resources>
And in the corresponding activity, set this new style
android:theme="@style/Theme.Styled"
and.. it works!