List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static final int getHeightInPx(Context context) { final int height = context.getResources().getDisplayMetrics().heightPixels; return height; }
From source file:Main.java
public static int getScreenWidth(Context context) { return (int) ((float) context.getResources().getDisplayMetrics().widthPixels + 0.5f); }
From source file:Main.java
public static boolean isTablet(Context context) { return context.getResources().getConfiguration().smallestScreenWidthDp >= 600; }
From source file:Main.java
/** * Get the current locale//from ww w.j a v a 2s .c om */ public static Locale getLocale(Context context) { return context.getResources().getConfiguration().locale; }
From source file:Main.java
public static int sp2dx(Context c, float sp) { return (int) (sp * c.getResources().getDisplayMetrics().density); }
From source file:Main.java
/** * Get dependent pixel. // www. ja v a 2 s . co m * * @param dp dependent pixel for convert. * @return number of dependent pixel. */ public static int getDependentPixel(int dp, Context context) { float scale = context.getResources().getDisplayMetrics().density; return (int) (dp * scale + 0.5f); }
From source file:Main.java
public static Drawable getDrawable(Context context, int resId) { return context.getResources().getDrawable(resId); }
From source file:Main.java
public final static String getSystemLocaleStringUsedAppStat(Context context) { Locale mlocale = context.getResources().getConfiguration().locale; return mlocale.toString().replace("_", "-"); }
From source file:Main.java
public static String getApplicationName(Context context) { Resources appR = context.getResources(); String txt = (String) appR.getText(appR.getIdentifier("app_name", "string", context.getPackageName())); return txt;// w w w .j av a 2 s . c om }
From source file:Main.java
public static boolean isVertical(Context context) { int orientacao = context.getResources().getConfiguration().orientation; boolean vertical = orientacao == Configuration.ORIENTATION_PORTRAIT; return vertical; }