android.content.res.Resources.Theme#resolveAttribute()源码实例Demo

下面列出了android.content.res.Resources.Theme#resolveAttribute() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Android-ContactPicker   文件: ContactBadge.java
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);
}
 
源代码2 项目: screenstandby   文件: IconContextMenu.java
@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;
}
 
源代码3 项目: mollyim-android   文件: ResUtil.java
public static int getDrawableRes(Theme theme, @AttrRes int attr) {
  final TypedValue out = new TypedValue();
  theme.resolveAttribute(attr, out, true);
  return out.resourceId;
}
 
源代码4 项目: deltachat-android   文件: ResUtil.java
public static int getDrawableRes(Theme theme, @AttrRes int attr) {
  final TypedValue out = new TypedValue();
  theme.resolveAttribute(attr, out, true);
  return out.resourceId;
}
 
源代码5 项目: Silence   文件: ResUtil.java
public static int getDrawableRes(Theme theme, @AttrRes int attr) {
  final TypedValue out = new TypedValue();
  theme.resolveAttribute(attr, out, true);
  return out.resourceId;
}
 
源代码6 项目: Overchan-Android   文件: ThemeUtils.java
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;
}
 
源代码7 项目: UltimateAndroid   文件: MaterialTabHost.java
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);
}
 
源代码8 项目: MeiZiNews   文件: ViewSetter.java
/**
 * 
 * @param newTheme
 * @param resId
 * @return
 */
protected int getColor(Theme newTheme) {
	TypedValue typedValue = new TypedValue();
	newTheme.resolveAttribute(mAttrResId, typedValue, true);
	return typedValue.data;
}
 
源代码9 项目: Colorful   文件: ViewSetter.java
/**
 * 
 * @param newTheme
 * @param resId
 * @return
 */
protected int getColor(Theme newTheme) {
	TypedValue typedValue = new TypedValue();
	newTheme.resolveAttribute(mAttrResId, typedValue, true);
	return typedValue.data;
}