List of usage examples for android.content Context getResources
public abstract Resources getResources();
From source file:Main.java
public static int convertDipToPx(Context context, int dp) { Resources r = context.getResources(); float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); return (int) px; }
From source file:Main.java
public static int getColor(Context context, final int mColorId) { return context.getResources().getColor(mColorId); }
From source file:Main.java
public static float convertDpToPixel(float dp, Context context) { Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); return dp * ((float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT); }
From source file:Main.java
public static final int getHeightInDp(Context context) { final float height = context.getResources().getDisplayMetrics().heightPixels; return px2dip(context, height); }
From source file:Main.java
public static int dp2px(Context context, int dp) { return (int) (dp * (context.getResources().getDisplayMetrics().density) + 0.5f); }
From source file:Main.java
public static float convertDpToFloatPixel(Context context, float dp) { Resources r = context.getResources(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()); }
From source file:Main.java
public static int getScreenWidth(Context context) { DisplayMetrics dm = context.getResources().getDisplayMetrics(); int screenWidth = dm.widthPixels; return screenWidth; }
From source file:Main.java
public static DisplayMetrics getScreenPixels(Context context) { Resources resources = context.getResources(); DisplayMetrics dm = resources.getDisplayMetrics(); return dm;//ww w.j av a 2 s . co m }
From source file:Main.java
public static int getDimenValue(Context context, int dimenId) { return (int) context.getResources().getDimension(dimenId); }
From source file:Main.java
public static Resources getResources(Context context) { return context.getResources(); }