Example usage for android.content.res Resources getDimensionPixelSize

List of usage examples for android.content.res Resources getDimensionPixelSize

Introduction

In this page you can find the example usage for android.content.res Resources getDimensionPixelSize.

Prototype

public int getDimensionPixelSize(@DimenRes int id) throws NotFoundException 

Source Link

Document

Retrieve a dimensional for a particular resource ID for use as a size in raw pixels.

Usage

From source file:Main.java

public static int getStatusBarHeight(Resources res) {
    int result = 0;
    int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        result = res.getDimensionPixelSize(resourceId);
    }/*w w w  .  j  a  v  a 2  s .  c  o m*/
    return result;
}

From source file:Main.java

/**
 *
 * @param context Context/*  w w  w . j av a 2  s. c om*/
 * @param name String
 * @return int
 */
public static int getPixelSizeByName(Context context, String name) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier(name, "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }
    return 0;
}

From source file:Main.java

public static int getBottomBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }//from ww w  .  j  a va 2  s  .co m
    return 0;
}

From source file:Main.java

public static int getNaviBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }// w w  w . j  a v  a2 s.com
    return 0;
}

From source file:Main.java

public static int getNavigationBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }/*from   ww  w.j  a  v  a  2  s  .  co m*/
    return 0;
}

From source file:Main.java

public static int getBarHeight(Resources res) {
    if (barHeight == 0) {
        int resourceId = res.getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            barHeight = res.getDimensionPixelSize(resourceId);
        }//from www. j a  v  a  2 s  .c  om
    }
    return barHeight;
}

From source file:Main.java

/**
 * Get status bar height/*  w w  w .j ava 2s  .  c om*/
 * @param context
 * @return
 */
public static int getStatusBarHeight(Context context) {
    int statusBarHeight = 0;
    Resources resource = context.getResources();
    int resourceId = resource.getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
        statusBarHeight = resource.getDimensionPixelSize(resourceId);
    }
    return statusBarHeight;
}

From source file:Main.java

public static int getNavigationBarHeight(Activity activity) {
    Resources resources = activity.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }/*ww  w . java  2 s  . co m*/
    return 0;
}

From source file:com.murrayc.galaxyzoo.app.UiUtils.java

static int getPxForDpResource(final Context context, final int resourceId) {
    final Resources r = context.getResources();
    return r.getDimensionPixelSize(resourceId);
}

From source file:Main.java

public static int getNavigationBarHeight(Context context) {
    Resources resources = context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) {
        return resources.getDimensionPixelSize(resourceId);
    }//from  w ww. java 2  s  .c o  m

    return 0;
}