List of usage examples for android.content.res TypedArray getColor
@ColorInt public int getColor(@StyleableRes int index, @ColorInt int defValue)
From source file:Main.java
public static int getStyledColor(Context context, int attrId) { TypedArray ta = getTypedArray(context, attrId); int color = ta.getColor(0, 0); ta.recycle();/*w w w . j a v a2 s . c om*/ return color; }
From source file:Main.java
private static int getTextColorFromStyle(Context ctx, int styleId) { TypedArray ta = ctx.obtainStyledAttributes(styleId, typeArray); int color = ta.getColor(0, DEFAULT_COLOR); ta.recycle();/*from www. j a va 2s .co m*/ return color; }
From source file:Main.java
public static int getAttributedColor(Context context, int attr) { int[] set = { attr }; TypedValue typedValue = new TypedValue(); TypedArray a = context.obtainStyledAttributes(typedValue.data, set); int color = a.getColor(0, Color.WHITE); a.recycle();/*ww w. j a v a 2s . c o m*/ return color; }
From source file:Main.java
public static int getThemeColor(Context context, int attrRes) { TypedArray typedArray = context.obtainStyledAttributes(new int[] { attrRes }); int color = typedArray.getColor(0, 0xffffff); typedArray.recycle();//w w w. j ava 2 s. co m return color; }
From source file:Main.java
public static int getColorFromContext(Context context, int color_id) { int[] textSizeAttr = new int[] { color_id }; TypedValue typedValue = new TypedValue(); TypedArray a = context.obtainStyledAttributes(typedValue.data, textSizeAttr); int color = a.getColor(0, 0); a.recycle();/*from ww w .j a v a 2s .c o m*/ return color; }
From source file:Main.java
public static int getThemeColorPrimaryDark(Context ctx) { TypedValue typedValue = new TypedValue(); ctx.getTheme().resolveAttribute(android.R.attr.theme, typedValue, true); int[] attribute = new int[] { android.R.attr.colorPrimaryDark }; TypedArray array = ctx.obtainStyledAttributes(typedValue.resourceId, attribute); int color = array.getColor(0, -1); array.recycle();/*ww w.j av a 2s .c om*/ return color; }
From source file:Main.java
public static int getThemeAttrColor(@NonNull Context context, @AttrRes int attr) { TypedArray a = context.obtainStyledAttributes(null, new int[] { attr }); try {//ww w .j a va 2 s.c o m return a.getColor(0, 0); } finally { a.recycle(); } }
From source file:Main.java
public static int resolveColor(Context context, int attr, int fallback) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attr }); try {/* www .ja va 2s . co m*/ return a.getColor(0, fallback); } finally { a.recycle(); } }
From source file:Main.java
public static int getAccentColor(Context context) { TypedValue typedValue = new TypedValue(); TypedArray typedArray = context.obtainStyledAttributes(typedValue.data, new int[] { 16843829 }); int accent = typedArray.getColor(0, 0); typedArray.recycle();//from w w w .j ava2 s .c o m return accent; }
From source file:Main.java
public static int getTextColorPrimary(Context context) { TypedValue typedValue = new TypedValue(); TypedArray typedArray = context.obtainStyledAttributes(typedValue.data, new int[] { 16842806 }); int accent = typedArray.getColor(0, 0); typedArray.recycle();//from w w w. j a v a 2 s . com return accent; }