List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:Main.java
public static int getThemeTextColorPrimary(Context context) { TypedValue textColorPrimary = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.textColorPrimary, textColorPrimary, true); return context.getResources().getColor(textColorPrimary.resourceId); }
From source file:Main.java
static int getActionBarHeight(Context context) { TypedValue tv = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { int actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); return actionBarHeight; }//from w w w . j av a 2s . c o m return 0; }
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 ww . ja v a 2 s . com return background; }
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();//from w w w . j a v a 2 s .c o m return background; }
From source file:Main.java
public static Drawable resolveDrawable(Context context, int attr, Drawable fallback) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attr }); try {//w w w . j av a 2 s . co m Drawable d = a.getDrawable(0); if (d == null && fallback != null) d = fallback; return d; } finally { a.recycle(); } }
From source file:Main.java
private static int resolveDimension(Context context, @AttrRes int attr, int fallback) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attr }); try {//from w ww .j ava2 s . c om return a.getDimensionPixelSize(0, fallback); } finally { a.recycle(); } }
From source file:Main.java
public static int resolveColor(Context context, @AttrRes int attr, int fallback) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attr }); try {//w w w . j a v a 2s . c om return a.getColor(0, fallback); } finally { a.recycle(); } }
From source file:Main.java
public static int getDrawableRes(Context c, @AttrRes int attr) { return getDrawableRes(c.getTheme(), attr); }
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 boolean resolveBoolean(Context context, @AttrRes int attr, boolean fallback) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attr }); try {// w w w. j a va 2s .c o m return a.getBoolean(0, fallback); } finally { a.recycle(); } }