List of usage examples for android.content Context obtainStyledAttributes
public final TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs)
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 ww w . j a v a2s.c o m return color; }
From source file:Main.java
@SuppressWarnings("ConstantConditions") public static float resolveFloat(Context context, int attr) { TypedArray a = context.obtainStyledAttributes(null, new int[] { attr }); try {/* w ww . ja v a 2 s .c om*/ return a.getFloat(0, 0); } finally { a.recycle(); } }
From source file:Main.java
public static int getThemeAttrColor(@NonNull Context context, @AttrRes int attr) { TypedArray a = context.obtainStyledAttributes(null, new int[] { attr }); try {/*from w ww . ja v a 2 s . c o m*/ return a.getColor(0, 0); } 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 a v a2 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();/* ww w .j a v a 2 s . co m*/ return accent; }
From source file:Main.java
public static int getPrimaryColor(Context context) { TypedValue typedValue = new TypedValue(); TypedArray typedArray = context.obtainStyledAttributes(typedValue.data, new int[] { 16843827 }); int accent = typedArray.getColor(0, 0); typedArray.recycle();/*from ww w. ja va 2 s . c o m*/ return accent; }
From source file:Main.java
public static int getTextColorSecondary(Context context) { TypedValue typedValue = new TypedValue(); TypedArray typedArray = context.obtainStyledAttributes(typedValue.data, new int[] { 16842808 }); int accent = typedArray.getColor(0, 0); typedArray.recycle();/* w w w.j a va 2s. c o m*/ return accent; }
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 . java 2 s. c o 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 w w w .j a v a 2 s. c om return color; }
From source file:android.support.v7.internal.widget.ThemeUtils.java
static int getThemeAttrColor(Context context, int attr) { TEMP_ARRAY[0] = attr;/*from ww w . jav a2 s .c om*/ TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY); try { return a.getColor(0, 0); } finally { a.recycle(); } }