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 getThemeAttrColor(Context context, int attributeColor) { context.getTheme().resolveAttribute(attributeColor, sTypedValue, true); return sTypedValue.data; }
From source file:Main.java
public static int getAttributeId(Context context, int style, int attr) { TypedArray a = context.getTheme().obtainStyledAttributes(style, new int[] { attr }); return a.getResourceId(0, 0); }
From source file:Main.java
public static int getActionBarHeight(Context context) { final TypedArray styledAttributes = context.getTheme() .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize }); int mActionBarSize = (int) styledAttributes.getDimension(0, 0); styledAttributes.recycle();//from ww w . j av a2s. co m return mActionBarSize; }
From source file:Main.java
public static int getToolBarHeight(Context context) { final TypedArray styledAttributes = context.getTheme() .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize }); int mActionBarSize = (int) styledAttributes.getDimension(0, 0); styledAttributes.recycle();/*from www.j a va2 s . com*/ return mActionBarSize; }
From source file:Main.java
public static int GetActionBarHeight(Context c) { TypedValue tv = new TypedValue(); if (c.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { int height = TypedValue.complexToDimensionPixelSize(tv.data, c.getResources().getDisplayMetrics()); return height; }// www. ja v a 2 s .c o m return 0; }
From source file:Main.java
public static int resolveColor(Context context, int attr, int fallback) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attr }); try {/*from w w w .ja va 2s . c o m*/ return a.getColor(0, fallback); } finally { a.recycle(); } }
From source file:Main.java
/** * get toolbar height/*w ww . ja va 2 s. c o m*/ * * @param context context * @return int */ public static int getToolbarHeight(Context context) { final TypedArray styledAttributes = context.getTheme() .obtainStyledAttributes(new int[] { android.R.attr.actionBarSize }); int toolbarHeight = (int) styledAttributes.getDimension(0, 0); styledAttributes.recycle(); return toolbarHeight; }
From source file:Main.java
public static int getActionBarHeight(Context context) { TypedValue tv = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { return TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics()); }/*from w w w . j av a 2 s .com*/ return 0; }
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();//from w w w . j a va 2 s . c o m return color; }
From source file:Main.java
/** * Get a resource id from an attribute id. * @param context/*from ww w .ja va 2s .co m*/ * @param attrId * @return the resource id */ public static int getResourceFromAttribute(Context context, int attrId) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[] { attrId }); int resId = a.getResourceId(0, 0); a.recycle(); return resId; }