Example usage for android.content.res Resources getSystem

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

Introduction

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

Prototype

public static Resources getSystem() 

Source Link

Document

Return a global shared Resources object that provides access to only system resources (no application resources), and is not configured for the current screen (can not use dimension units, does not change based on orientation, etc).

Usage

From source file:Main.java

public static int transDip(int dip) {
    float scale = Resources.getSystem().getDisplayMetrics().density;
    return (int) (dip * scale + 0.5f);
}

From source file:Main.java

public static int getNavigationBarHeight() {
    return Resources.getSystem().getDimensionPixelSize(
            Resources.getSystem().getIdentifier("navigation_bar_height", "dimen", "android"));
}

From source file:Main.java

public static int dp2px(int dp) {
    return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}

From source file:Main.java

public static float pxToDp(float px) {
    float densityDpi = Resources.getSystem().getDisplayMetrics().densityDpi;
    return px / (densityDpi / 160f);
}

From source file:Main.java

public static final int dpToPx(int dp) {
    return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
}

From source file:Main.java

public static int px2dp(float pxValue) {
    final float scale = Resources.getSystem().getDisplayMetrics().density;
    return (int) (pxValue / scale + 0.5f);
}

From source file:Main.java

public static int dp2px(float dipValue) {
    final float scale = Resources.getSystem().getDisplayMetrics().density;
    return (int) (dipValue * scale + 0.5f);
}

From source file:Main.java

public static int px2sp(float pxValue) {
    final float fontScale = Resources.getSystem().getDisplayMetrics().scaledDensity;
    return (int) (pxValue / fontScale + 0.5f);
}

From source file:Main.java

public static int GetScreenWidth() {
    return Resources.getSystem().getDisplayMetrics().widthPixels;
}

From source file:Main.java

public static int GetScreenHeight() {
    return Resources.getSystem().getDisplayMetrics().heightPixels;
}