List of usage examples for android.util TypedValue TypedValue
TypedValue
From source file:Main.java
public static String resolveString(Context context, @AttrRes int attr) { TypedValue v = new TypedValue(); context.getTheme().resolveAttribute(attr, v, true); return (String) v.string; }
From source file:Main.java
public static Drawable getActionBarBackground(Context context) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true); TypedArray typedArray = context.obtainStyledAttributes(outValue.resourceId, new int[] { android.R.attr.background }); Drawable background = typedArray.getDrawable(0); typedArray.recycle();//from w w w. j av a2 s .co m return background; }
From source file:Main.java
public static int getThemeColor(Context context, @AttrRes final int id) { TypedValue typedValue = new TypedValue(); context.getTheme().resolveAttribute(id, typedValue, true); return typedValue.data; }
From source file:Main.java
public static Drawable getSplitActionBarBackground(Context context) { TypedValue outValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true); TypedArray typedArray = context.obtainStyledAttributes(outValue.resourceId, new int[] { android.R.attr.backgroundSplit }); Drawable background = typedArray.getDrawable(0); typedArray.recycle();/* www. j a v a2 s .c o m*/ return background; }
From source file:Main.java
static int resolveColorAttribute(Context context, @AttrRes int resId, int fallback) { TypedValue value = new TypedValue(); boolean colorFound = context.getTheme().resolveAttribute(resId, value, true); return colorFound ? value.data : fallback; }
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();/*from w ww . j a va 2 s .co m*/ return color; }
From source file:Main.java
public static int resolveColorAttribute(Context context, @AttrRes int resId, int fallback) { TypedValue value = new TypedValue(); boolean colorFound = context.getTheme().resolveAttribute(resId, value, true); return colorFound ? value.data : fallback; }
From source file:Main.java
/** * Get ActionBar size./*from w w w .j av a 2s. c om*/ */ public static int getActionBarSize(Context context) { int actionBarSize = 0; TypedValue tv = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarSize = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); } return actionBarSize; }
From source file:Main.java
public static TypedValue getValue(Context context, int attr) { TypedArray ta = context.obtainStyledAttributes(new int[] { attr }); TypedValue tv = new TypedValue(); boolean bool = ta.getValue(0, tv); ta.recycle();//from www . ja v a 2s.c om if (bool == true) return tv; return null; }
From source file:Main.java
@Nullable public static Drawable getAttributeDrawable(Context context, int attributeId) { TypedValue typedValue = new TypedValue(); context.getTheme().resolveAttribute(attributeId, typedValue, true); return context.getResources().getDrawable(typedValue.resourceId); }