Search code examples
androidandroid-actionbarheightactionbarsherlock

Android actionbarsherlock get height return 0


I was looking for get the height of my actionbar(sherlock). The value returned is 0.

value/styles.xml (and for value11 I used "android:actionBarSize")

<style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarStyle">@style/Widget.AppTheme.ActionBar</item>
    <item name="actionBarSize">48dip</item>
</style>

code :

getSupportActionBar().getHeight()

Solution

  • This didn't work?

    // Calculate ActionBar height
    TypedValue tv = new TypedValue();
    if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
    {
        actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,getResources().getDisplayMetrics());
    }
    

    ref: How to get the ActionBar height?