Example usage for android.content.res TypedArray getDimension

List of usage examples for android.content.res TypedArray getDimension

Introduction

In this page you can find the example usage for android.content.res TypedArray getDimension.

Prototype

public float getDimension(@StyleableRes int index, float defValue) 

Source Link

Document

Retrieve a dimensional unit attribute at index.

Usage

From source file:Main.java

public static int getActionBarHeight(Context context) {
    int[] attrs = new int[] { android.R.attr.actionBarSize };
    TypedArray styledAttributes = context.getTheme().obtainStyledAttributes(attrs);
    int actionBarHeight = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();/*from w w  w .j a  va  2  s  . c o m*/
    return actionBarHeight;
}

From source file:Main.java

public static float getDimension(Context context, @StyleRes int styleResId, @AttrRes int attr) {
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(styleResId, new int[] { attr });
    float size = typedArray.getDimension(0, 0);
    typedArray.recycle();// w w w  . jav  a2  s  .c  om
    return size;
}

From source file:Main.java

public static int getActionBarHeight(Context context) {

    if (mActionBarHeight != -1) {
        return mActionBarHeight;
    }//from   w  w  w  .  j a  v  a  2 s . com

    TypedArray typedArray = context.obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    mActionBarHeight = (int) typedArray.getDimension(0, 0);
    typedArray.recycle();

    return mActionBarHeight;
}

From source file:Main.java

public static int getActionBarHeight(Context context) {
    final TypedArray styledAttributes = context.getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();/*w  w w. j  a  v a2  s.  c o m*/
    return mActionBarSize;
}

From source file:Main.java

public static int getToolBarHeight(Context context) {
    final TypedArray styledAttributes = context.getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    int mActionBarSize = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();//www  .j  a  v  a 2 s.c  om
    return mActionBarSize;
}

From source file:Main.java

public static int getActionBarHeight(Context c) {

    int mActionBarSize;

    final TypedArray styledAttributes = c.getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    mActionBarSize = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();/*from  www  . j av a2 s.c  om*/

    return mActionBarSize;

}

From source file:Main.java

/**
 * get toolbar height//www  .  j  a  v a 2 s.c o  m
 *
 * @param context context
 * @return int
 */
public static int getToolbarHeight(Context context) {
    final TypedArray styledAttributes = context.getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    int toolbarHeight = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();

    return toolbarHeight;
}

From source file:com.mytwitter.Utils.Utils.java

public static int getToolbarHeight2(Context context) {
    final TypedArray styledAttributes = context.getTheme()
            .obtainStyledAttributes(new int[] { R.attr.actionBarSize });
    int toolbarHeight = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();/*from   ww w  .  ja v a2s  .c o  m*/

    return toolbarHeight;
}

From source file:com.zzc.androidtrain.view.refresh.Utils.java

public static int getActionBarSize(Context context) {
    TypedArray styledAttributes = context.getTheme()
            .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize });
    int size = (int) styledAttributes.getDimension(0, 0);
    styledAttributes.recycle();//  ww w .  j a v  a2  s .  c  o  m
    return size;
}

From source file:com.grarak.kerneladiutor.utils.ViewUtils.java

public static float getActionBarSize(Context context) {
    TypedArray typedArray = context.obtainStyledAttributes(new int[] { R.attr.actionBarSize });
    float size = typedArray.getDimension(0, 0);
    typedArray.recycle();//  ww  w .  j av  a 2s . com
    return size;
}