Java 类android.support.v7.widget.AppCompatImageHelper 实例源码

项目:boohee_v5.6    文件:FloatingActionButton.java   
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.mShadowPadding = new Rect();
    ThemeUtils.checkAppCompatTheme(context);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.Widget_Design_FloatingActionButton);
    this.mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint);
    this.mBackgroundTintMode = parseTintMode(a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null);
    this.mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
    this.mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, 0);
    this.mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
    float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0.0f);
    float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0.0f);
    this.mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
    a.recycle();
    this.mImageHelper = new AppCompatImageHelper(this, AppCompatDrawableManager.get());
    this.mImageHelper.loadFromAttributes(attrs, defStyleAttr);
    this.mImagePadding = (getSizeDimension() - ((int) getResources().getDimension(R.dimen.design_fab_image_size))) / 2;
    getImpl().setBackgroundDrawable(this.mBackgroundTint, this.mBackgroundTintMode, this.mRippleColor, this.mBorderWidth);
    getImpl().setElevation(elevation);
    getImpl().setPressedTranslationZ(pressedTranslationZ);
    getImpl().updatePadding();
}
项目:Carbon    文件:ImageView.java   
private void initImageView(AttributeSet attrs, int defStyleAttr) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.ImageView, defStyleAttr, R.style.carbon_ImageView);

    for (int i = 0; i < a.getIndexCount(); i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.ImageView_android_src) {
            int resId = a.getResourceId(attr, 0);
            if (resId != 0 && getContext().getResources().getResourceTypeName(resId).equals("raw")) {
                if (!isInEditMode()) {
                    setImageDrawable(new VectorDrawable(getResources(), resId));
                } else {
                    setImageResource(R.drawable.carbon_iconplaceholder);
                }
            }
        } else if (attr == R.styleable.ImageView_android_enabled) {
            setEnabled(a.getBoolean(attr, true));
        } else if (attr == R.styleable.ImageView_carbon_cornerRadius) {
            setCornerRadius(a.getDimension(attr, 0));
        }
    }

    new AppCompatImageHelper(this).loadFromAttributes(attrs, defStyleAttr);

    Carbon.initDefaultBackground(this, a, R.styleable.ImageView_android_background);

    Carbon.initElevation(this, a, elevationIds);
    Carbon.initRippleDrawable(this, a, rippleIds);
    Carbon.initAnimations(this, a, animationIds);
    Carbon.initTouchMargin(this, a, touchMarginIds);
    Carbon.initTint(this, a, tintIds);
    Carbon.initStroke(this, a, strokeIds);

    a.recycle();
}
项目:iosched    文件:FloatingActionButton.java   
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  ThemeUtils.checkAppCompatTheme(context);

  TypedArray a =
      context.obtainStyledAttributes(
          attrs,
          R.styleable.FloatingActionButton,
          defStyleAttr,
          R.style.Widget_Design_FloatingActionButton);
  mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint);
  mBackgroundTintMode =
      ViewUtils.parseTintMode(
          a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null);
  mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
  mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO);
  mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
  final float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0f);
  final float pressedTranslationZ =
      a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f);
  mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
  a.recycle();

  mImageHelper = new AppCompatImageHelper(this);
  mImageHelper.loadFromAttributes(attrs, defStyleAttr);

  mMaxImageSize = (int) getResources().getDimension(R.dimen.design_fab_image_size);

  getImpl()
      .setBackgroundDrawable(mBackgroundTint, mBackgroundTintMode, mRippleColor, mBorderWidth);
  getImpl().setElevation(elevation);
  getImpl().setPressedTranslationZ(pressedTranslationZ);
}
项目:material-components-android    文件:FloatingActionButton.java   
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  ThemeEnforcement.checkAppCompatTheme(context);

  TypedArray a =
      context.obtainStyledAttributes(
          attrs,
          R.styleable.FloatingActionButton,
          defStyleAttr,
          R.style.Widget_Design_FloatingActionButton);
  backgroundTint =
      MaterialResources.getColorStateList(
          context, a, R.styleable.FloatingActionButton_backgroundTint);
  backgroundTintMode =
      ViewUtils.parseTintMode(
          a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null);
  rippleColor =
      MaterialResources.getColorStateList(
          context, a, R.styleable.FloatingActionButton_rippleColor);
  size = a.getInt(R.styleable.FloatingActionButton_fabSize, SIZE_AUTO);
  customSize =
      a.getDimensionPixelSize(R.styleable.FloatingActionButton_fabCustomSize, NO_CUSTOM_SIZE);
  borderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
  final float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0f);
  final float hoveredFocusedTranslationZ =
      a.getDimension(R.styleable.FloatingActionButton_hoveredFocusedTranslationZ, 0f);
  final float pressedTranslationZ =
      a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0f);
  compatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
  maxImageSize = a.getDimensionPixelSize(R.styleable.FloatingActionButton_maxImageSize, 0);

  MotionSpec showMotionSpec =
      MotionSpec.createFromAttribute(
          context, a, R.styleable.FloatingActionButton_showMotionSpec);
  MotionSpec hideMotionSpec =
      MotionSpec.createFromAttribute(
          context, a, R.styleable.FloatingActionButton_hideMotionSpec);

  a.recycle();

  imageHelper = new AppCompatImageHelper(this);
  imageHelper.loadFromAttributes(attrs, defStyleAttr);

  expandableWidgetHelper = new ExpandableWidgetHelper(this);

  getImpl().setBackgroundDrawable(backgroundTint, backgroundTintMode, rippleColor, borderWidth);
  getImpl().setElevation(elevation);
  getImpl().setHoveredFocusedTranslationZ(hoveredFocusedTranslationZ);
  getImpl().setPressedTranslationZ(pressedTranslationZ);
  getImpl().setMaxImageSize(maxImageSize);
  getImpl().setShowMotionSpec(showMotionSpec);
  getImpl().setHideMotionSpec(hideMotionSpec);

  setScaleType(ScaleType.MATRIX);
}