List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static int dip2px(Context mContext, float dipValue) { float scale = mContext.getResources().getDisplayMetrics().density; return (int) (dipValue * scale + 0.5F); }
From source file:Main.java
public static Bitmap getResBitmap(Context context, int resId) { Resources res = context.getResources(); return BitmapFactory.decodeResource(res, resId); }
From source file:Main.java
public static float dp2pixel(Context context, int dp) { Resources r = context.getResources(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); }
From source file:Main.java
public static int dip2px(Context context, int dipValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dipValue * scale + 0.5f); }
From source file:Main.java
public static int dip2px(Context context, float dipValue) { float density = context.getResources().getDisplayMetrics().density; return (int) (dipValue * density + 0.5f); }
From source file:Main.java
public static int dimen2px(Context context, int dimenId) { return context.getResources().getDimensionPixelOffset(dimenId); }
From source file:Main.java
public static float dpFromPx(final Context context, final float px) { return px / context.getResources().getDisplayMetrics().density; }
From source file:Main.java
/** * Used to determine if the device is a tablet or not * /*www . j a v a2 s.c om*/ * @param context The {@link Context} to use. * @return True if the device is a tablet, false otherwise. */ public static final boolean isTablet(final Context context) { return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE; }
From source file:Main.java
public static String getStringFromResourceWithText(Context context, int idResource, String text) { return context.getResources().getString(idResource, text); }