get ActionBar Height - Android User Interface

Android examples for User Interface:ActionBar Size

Description

get ActionBar Height

Demo Code


//package com.java2s;

import android.content.Context;

import android.util.TypedValue;

public class Main {
    public static int getActionBarHeight(Context context) {
        TypedValue tv = new TypedValue();
        int actionBarHeight = 0;
        if (context.getTheme().resolveAttribute(
                android.R.attr.actionBarSize, tv, true))
        {/*from w ww .j  a  va  2 s  .c  om*/
            actionBarHeight = TypedValue.complexToDimensionPixelSize(
                    tv.data, context.getResources().getDisplayMetrics());
        }
        return actionBarHeight;
    }
}

Related Tutorials