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 float density() {
    return Resources.getSystem().getDisplayMetrics().density;
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static float pxToSp(float px) {
    return (px / Resources.getSystem().getDisplayMetrics().scaledDensity);
}

From source file:Main.java

public static float pxToDp(float px) {
    return (px / Resources.getSystem().getDisplayMetrics().density);
}

From source file:Main.java

public static float spToPx(float sp) {
    return (sp * Resources.getSystem().getDisplayMetrics().scaledDensity);
}

From source file:Main.java

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

From source file:Main.java

public static int spToPx(int sp) {
    return (int) (sp * Resources.getSystem().getDisplayMetrics().scaledDensity);
}

From source file:Main.java

public static int pxToSp(int px) {
    return (int) (px / Resources.getSystem().getDisplayMetrics().scaledDensity);
}

From source file:Main.java

public static int pxToDp(int px) {
    return (int) (px / Resources.getSystem().getDisplayMetrics().density);
}