List of usage examples for android.content.res Resources getDisplayMetrics
public DisplayMetrics getDisplayMetrics()
From source file:Main.java
public static DisplayMetrics getDisplayMetrics(Context context) { Resources res; if (context == null) { res = Resources.getSystem(); } else {//from w w w . j ava 2s. c o m res = context.getResources(); } return res.getDisplayMetrics(); }
From source file:Main.java
public static int sp2px(float value, Context context) { Resources r; if (context == null) { r = Resources.getSystem(); } else {//from w ww.j a v a2 s . c o m r = context.getResources(); } float spvalue = value * r.getDisplayMetrics().scaledDensity; return (int) (spvalue + 0.5f); }
From source file:Main.java
public static int sp2px(float value) { Resources r; if (mContext == null) { r = Resources.getSystem(); } else {/* www. j a va 2s .c om*/ r = mContext.getResources(); } float spvalue = value * r.getDisplayMetrics().scaledDensity; return (int) (spvalue + 0.5f); }
From source file:Main.java
public static float getRawSize(Context context, int unit, float size) { Resources r; if (context == null) r = Resources.getSystem(); else//from www. j a v a 2 s . c o m r = context.getResources(); return TypedValue.applyDimension(unit, size, r.getDisplayMetrics()); }
From source file:Main.java
public static void updateResources(Context context, String language) { //set the language of the app Locale locale = new Locale(language); Locale.setDefault(locale);/*from w w w. j av a 2s . c om*/ Resources resources = context.getResources(); Configuration configuration = resources.getConfiguration(); configuration.locale = locale; resources.updateConfiguration(configuration, resources.getDisplayMetrics()); }
From source file:com.micabytes.gfx.ImageHandler.java
private static void setDensity() { if (density < DENSITY_MINIMUM) { Context context = GameApplication.getInstance(); Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); density = metrics.density;//from w w w .j av a 2 s. c o m } }
From source file:Main.java
private static void updateResources(Context context, String language) { Locale locale = new Locale(language); Locale.setDefault(locale);//from w w w.ja v a 2 s . c o m Resources resources = context.getResources(); Configuration configuration = resources.getConfiguration(); configuration.locale = locale; resources.updateConfiguration(configuration, resources.getDisplayMetrics()); }
From source file:Main.java
public static void updateApplicationResourceLocale(Context context, Locale locale) { Resources resources = context.getResources(); Configuration configuration = resources.getConfiguration(); if (!configuration.locale.equals(locale)) { android.util.DisplayMetrics displaymetrics = resources.getDisplayMetrics(); configuration.locale = locale;/*w w w . j a va2 s .c o m*/ resources.updateConfiguration(configuration, displaymetrics); Resources.getSystem().updateConfiguration(configuration, displaymetrics); } }
From source file:com.andryr.guitartuner.Utils.java
public static float dpToPixels(Context context, float dp) { Resources r = context.getResources(); return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, r.getDisplayMetrics()); }
From source file:Main.java
private static void updateResources(Context context, String language) { Locale locale = new Locale(language); Locale.setDefault(locale);//from www .j a v a 2 s . co m Resources resources = context.getResources(); Configuration configuration = new Configuration(resources.getConfiguration()); configuration.locale = locale; resources.updateConfiguration(configuration, resources.getDisplayMetrics()); }