Java Code Examples for android.content.res.Resources.Theme#resolveAttribute()
The following examples show how to use
android.content.res.Resources.Theme#resolveAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContactBadge.java From Android-ContactPicker with Apache License 2.0 | 5 votes |
private void initOverlay(Context context, Shape shape) { // pressed state TypedValue typedValue = new TypedValue(); Theme theme = context.getTheme(); mPressedOverlay = new ShapeDrawable(shape); int overlayColor = Color.parseColor("#aa888888"); if (theme.resolveAttribute(R.attr.cp_badgeOverlayColor, typedValue, true)) { overlayColor = typedValue.data; } Paint paint = mPressedOverlay.getPaint(); paint.setColor(overlayColor); paint.setStyle(Paint.Style.FILL); paint.setAntiAlias(true); }
Example 2
Source File: IconContextMenu.java From screenstandby with GNU General Public License v2.0 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { IconContextMenuItem item = (IconContextMenuItem) getItem(position); Resources res = parentActivity.getResources(); if (convertView == null) { TextView temp = new TextView(context); AbsListView.LayoutParams param = new AbsListView.LayoutParams(AbsListView.LayoutParams.FILL_PARENT, AbsListView.LayoutParams.WRAP_CONTENT); temp.setLayoutParams(param); temp.setPadding((int)toPixel(res, 20), 2, (int)toPixel(res, 20), 2); temp.setGravity(android.view.Gravity.CENTER_VERTICAL); Theme th = context.getTheme(); TypedValue tv = new TypedValue(); if (th.resolveAttribute(android.R.attr.textAppearanceLargeInverse, tv, true)) { temp.setTextAppearance(context, tv.resourceId); } temp.setMinHeight(LIST_PREFERED_HEIGHT); temp.setCompoundDrawablePadding((int)toPixel(res, 14)); convertView = temp; } TextView textView = (TextView) convertView; textView.setTag(item); textView.setText(item.text); textView.setTextColor(Color.WHITE); textView.setTypeface(typeface); Bitmap bitmap = ((BitmapDrawable) item.image).getBitmap(); Drawable d = new BitmapDrawable(parent.getResources(), Bitmap.createScaledBitmap(bitmap, LIST_PREFERED_HEIGHT, LIST_PREFERED_HEIGHT, true)); textView.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); return textView; }
Example 3
Source File: ResUtil.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public static int getDrawableRes(Theme theme, @AttrRes int attr) { final TypedValue out = new TypedValue(); theme.resolveAttribute(attr, out, true); return out.resourceId; }
Example 4
Source File: ResUtil.java From deltachat-android with GNU General Public License v3.0 | 4 votes |
public static int getDrawableRes(Theme theme, @AttrRes int attr) { final TypedValue out = new TypedValue(); theme.resolveAttribute(attr, out, true); return out.resourceId; }
Example 5
Source File: ResUtil.java From Silence with GNU General Public License v3.0 | 4 votes |
public static int getDrawableRes(Theme theme, @AttrRes int attr) { final TypedValue out = new TypedValue(); theme.resolveAttribute(attr, out, true); return out.resourceId; }
Example 6
Source File: ThemeUtils.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
private static void resolveAttribute(Theme theme, int attrId, TypedValue outValue, boolean resolveRefs) { if (CustomThemeHelper.resolveAttribute(attrId, outValue)) return; if (!theme.resolveAttribute(attrId, outValue, resolveRefs)) outValue.type = TypedValue.TYPE_NULL; }
Example 7
Source File: MaterialTabHost.java From UltimateAndroid with Apache License 2.0 | 4 votes |
public MaterialTabHost(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); super.setOverScrollMode(this.OVER_SCROLL_NEVER); layout = new LinearLayout(context); this.addView(layout); // get primary and accent color from AppCompat theme Theme theme = context.getTheme(); TypedValue typedValue = new TypedValue(); theme.resolveAttribute(R.attr.colorPrimary, typedValue, true); primaryColor = typedValue.data; theme.resolveAttribute(R.attr.colorAccent, typedValue, true); accentColor = typedValue.data; iconColor = Color.WHITE; textColor = Color.WHITE; // get attributes if(attrs != null) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MaterialTabHost, 0, 0); try { hasIcons = a.getBoolean(R.styleable.MaterialTabHost_hasIcons, false); } finally { a.recycle(); } } else { hasIcons = false; } this.isInEditMode(); density = this.getResources().getDisplayMetrics().density; scrollable = false; isTablet = this.getResources().getBoolean(R.bool.isTablet); // initialize tabs list tabs = new LinkedList<MaterialTab>(); tabsWidth = new LinkedList<Integer>(); // set background color super.setBackgroundColor(primaryColor); }
Example 8
Source File: ViewSetter.java From MeiZiNews with MIT License | 2 votes |
/** * * @param newTheme * @param resId * @return */ protected int getColor(Theme newTheme) { TypedValue typedValue = new TypedValue(); newTheme.resolveAttribute(mAttrResId, typedValue, true); return typedValue.data; }
Example 9
Source File: ViewSetter.java From Colorful with MIT License | 2 votes |
/** * * @param newTheme * @param resId * @return */ protected int getColor(Theme newTheme) { TypedValue typedValue = new TypedValue(); newTheme.resolveAttribute(mAttrResId, typedValue, true); return typedValue.data; }