List of usage examples for android.content Context getTheme
@ViewDebug.ExportedProperty(deepExport = true) public abstract Resources.Theme getTheme();
From source file:Main.java
/** * @Description:/*from ww w . j a v a 2s . c o m*/ * @param applicationContext * @return */ public static int getHeightActionBar(Context context) { int height; TypedValue typeValue = new TypedValue(); context.getTheme().resolveAttribute(android.R.attr.actionBarSize, typeValue, true); height = TypedValue.complexToDimensionPixelSize(typeValue.data, context.getResources().getDisplayMetrics()); return height; }
From source file:Main.java
public static int fromAttribute(Context context, int attr) { TypedValue typedValue = new TypedValue(); Resources.Theme theme = context.getTheme(); theme.resolveAttribute(attr, typedValue, true); return typedValue.data; }
From source file:Main.java
/** * Get ActionBar size./* w w w . j a v a 2 s . co m*/ */ 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 int getColor(Context context, int attr) { TypedValue typedValue = new TypedValue(); Resources.Theme theme = context.getTheme(); theme.resolveAttribute(attr, typedValue, true); int color = typedValue.data; return color; }
From source file:Main.java
static int getActionbarSize(Context context) { int actionbarSize = -1; TypedValue typedValue = new TypedValue(); if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, typedValue, true)) { actionbarSize = TypedValue.complexToDimensionPixelSize(typedValue.data, context.getResources().getDisplayMetrics()); }//w w w . ja v a 2s.c o m return actionbarSize; }
From source file:Main.java
public static int getActionBarHeight(Context context) { if (sActionBarHeight != 0) { return sActionBarHeight; }/*from w w w . jav a 2 s . c o m*/ context.getTheme().resolveAttribute(android.R.attr.actionBarSize, sTypedValue, true); sActionBarHeight = TypedValue.complexToDimensionPixelSize(sTypedValue.data, context.getResources().getDisplayMetrics()); return sActionBarHeight; }
From source file:com.mytwitter.Utils.Utils.java
public static int getToolbarHeight2(Context context) { final TypedArray styledAttributes = context.getTheme() .obtainStyledAttributes(new int[] { R.attr.actionBarSize }); int toolbarHeight = (int) styledAttributes.getDimension(0, 0); styledAttributes.recycle();//from w w w . j ava 2 s .c om return toolbarHeight; }
From source file:Main.java
public static int getActionBarHeight(Context context) { int[] attrs = new int[] { android.R.attr.actionBarSize }; TypedArray styledAttributes = context.getTheme().obtainStyledAttributes(attrs); int actionBarHeight = (int) styledAttributes.getDimension(0, 0); styledAttributes.recycle();/*w w w. j a v a2 s. co m*/ return actionBarHeight; }
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 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; }