List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static String getLanguage(Context c) { if (c != null) return c.getResources().getConfiguration().locale.getLanguage(); return null;//from ww w . j av a 2s .c o m }
From source file:Main.java
/** * Used to determine if the device is currently in landscape mode * /*w w w . j a va 2 s . co m*/ * @param context The {@link Context} to use. * @return True if the device is in landscape mode, false otherwise. */ public static final boolean isLandscape(final Context context) { return context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; }
From source file:Main.java
public static int px2dip(Context context, int pxValue) { float density = context.getResources().getDisplayMetrics().density; return (int) (pxValue / density + 0.5f); }
From source file:Main.java
/** * Determining the current screen's size is xlarge or not.. * /*from w ww . j av a 2 s . c om*/ * @param context * The Application Context. * @return Boolean Type. */ public static boolean isXLarge(Context context) { return ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE); }
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 w w w . ja va 2 s.c o m return 0; }
From source file:Main.java
public static int dip2px(Context context, int dip) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dip * scale + 0.5f); }
From source file:Main.java
public static int dp2px(Context context, float dp) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dp * scale + 0.5f); }
From source file:Main.java
public static int px2dip(Context context, float pxValue) { float scale = context.getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5f); }
From source file:Main.java
public static int convertDpToPixel(float dp, Context context) { Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); float px = dp * (metrics.densityDpi / 160f); return (int) px; }
From source file:Main.java
public static float px2dp(Context context, float size) { return size / context.getResources().getDisplayMetrics().density; }