Android ActionBar Set getActionBarSize(Context context)

Here you can find the source of getActionBarSize(Context context)

Description

Get the action bar size in pixel.

Parameter

Parameter Description
context the android.content.Context used to retrieve the theme.

Declaration

public static int getActionBarSize(Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;
import android.content.res.TypedArray;

public class Main {
    /**//from w w  w  .j  a v a  2  s.  c  o  m
     * Get the action bar size in pixel.
     *
     * @param context the {@link android.content.Context} used to retrieve the theme.
     * @return
     */
    public static int getActionBarSize(Context context) {
        final TypedArray styledAttributes = context.getTheme()
                .obtainStyledAttributes(
                        new int[] { android.R.attr.actionBarSize });
        final int actionBarSize = (int) styledAttributes.getDimension(0, 0);
        styledAttributes.recycle();
        return actionBarSize;
    }
}

Related

  1. setColor(ActionBarActivity activity, int colorRes, Drawable oldBackground, Drawable.Callback drawableCallback)