List of usage examples for android.content.res Resources getColor
@ColorInt @Deprecated public int getColor(@ColorRes int id) throws NotFoundException
From source file:Main.java
public static int getColor(Resources res, int resId) { return res.getColor(resId); }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getColorOld(Resources resources, int colorResourceId) { return resources.getColor(colorResourceId); }
From source file:Main.java
public static int getColor(Context context, int res) { Resources resource = context.getResources(); return resource.getColor(res); }
From source file:Main.java
public static int[] getColorArray(Context context) { int length = sColorArray.size() / 2; int[] colorArray = new int[length]; Resources res = context.getResources(); for (int i = 0; i < length; i++) { colorArray[i] = res.getColor(sColorArray.get(i)); }/*from w w w .j av a 2s . c om*/ return colorArray; }
From source file:Main.java
public static int getColor(Resources res, Resources.Theme theme, @ColorRes int id) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { return res.getColor(id); }//w ww . ja v a 2 s . c om return res.getColor(id, theme); }
From source file:Main.java
public static int getColor(Context context, int colorRes) { Resources resources = context.getResources(); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) { return resources.getColor(colorRes); } else {/*from www .ja v a2s . c o m*/ return resources.getColor(colorRes, null); } }
From source file:com.android.contacts.util.MaterialColorMapUtils.java
public static MaterialPalette getDefaultPrimaryAndSecondaryColors(Resources resources) { final int primaryColor = resources.getColor(R.color.quickcontact_default_photo_tint_color); final int secondaryColor = resources.getColor(R.color.quickcontact_default_photo_tint_color_dark); return new MaterialPalette(primaryColor, secondaryColor); }
From source file:Main.java
public static int loadThemeColor(Resources themeResources, String resourceName, String themePackage) { int color = 0; int resource_id = themeResources.getIdentifier(resourceName, "color", themePackage); if (resource_id != 0) { color = themeResources.getColor(resource_id); }/* w w w .j ava2 s . c om*/ return color; }
From source file:com.example.madiba.venu_alpha.utils.ColorUtils.java
public static Drawable colorDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId, Context context) {//w w w . j a va2s . c o m Drawable drawable = ContextCompat.getDrawable(context, drawableResId); int color = res.getColor(colorResId); drawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN); return drawable; }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getColor(@NonNull Context context, @ColorRes int color) { final Resources resources = context.getResources(); // TODO: After switching to Android M SDK: Use getColor(color, theme) on Android M+ // if (AppConstants.Versions.feature23Plus) { // return resources.getColor(color, context.getTheme()); // }/*from ww w .j av a2 s . c om*/ return resources.getColor(color); }