android.graphics.drawable.Drawable.onStateChange()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(239)

本文整理了Java中android.graphics.drawable.Drawable.onStateChange()方法的一些代码示例,展示了Drawable.onStateChange()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Drawable.onStateChange()方法的具体详情如下:
包路径:android.graphics.drawable.Drawable
类名称:Drawable
方法名:onStateChange

Drawable.onStateChange介绍

暂无

代码示例

代码示例来源:origin: vinc3m1/RoundedImageView

@Override
protected boolean onStateChange(int[] state) {
 int newColor = mBorderColor.getColorForState(state, 0);
 if (mBorderPaint.getColor() != newColor) {
  mBorderPaint.setColor(newColor);
  return true;
 } else {
  return super.onStateChange(state);
 }
}

代码示例来源:origin: facebook/litho

@Override
protected boolean onStateChange(int[] states) {
 if (mColorStateList != null && mLayout != null) {
  final int previousColor = mLayout.getPaint().getColor();
  final int currentColor = mColorStateList.getColorForState(states, mUserColor);
  if (currentColor != previousColor) {
   mLayout.getPaint().setColor(currentColor);
   invalidateSelf();
  }
 }
 return super.onStateChange(states);
}

代码示例来源:origin: ZieIony/Carbon

@Override
protected boolean onStateChange(int[] states) {
  boolean changed = false;
  if (states != null) {
    boolean newChecked = false;
    boolean newIndeterminate = false;
    boolean newEnabled = false;
    for (int state : states) {
      if (state == android.R.attr.state_checked)
        newChecked = true;
      if (state == R.attr.carbon_state_indeterminate)
        newIndeterminate = true;
      if (state == android.R.attr.state_enabled)
        newEnabled = true;
    }
    CheckedState newCheckedState = newIndeterminate ? CheckedState.INDETERMINATE : newChecked ? CheckedState.CHECKED : CheckedState.UNCHECKED;
    if (checkedState != newCheckedState) {
      setChecked(newCheckedState);
      changed = true;
    }
    if (enabled != newEnabled) {
      setEnabled(newEnabled);
      changed = true;
    }
  }
  boolean result = super.onStateChange(states);
  if (changed && tint != null && tint instanceof AnimatedColorStateList)
    ((AnimatedColorStateList) tint).setState(states);
  return result && changed;
}

代码示例来源:origin: jrvansuita/MaterialAbout

@Override
protected boolean onStateChange(int[] state) {
  int newColor = mBorderColor.getColorForState(state, 0);
  if (mBorderPaint.getColor() != newColor) {
    mBorderPaint.setColor(newColor);
    return true;
  } else {
    return super.onStateChange(state);
  }
}

代码示例来源:origin: PrivacyApps/document-viewer

@Override
protected boolean onStateChange(int[] state) {
  invalidateSelf();
  return super.onStateChange(state);
}

代码示例来源:origin: open-android/RoundedImageView

@Override
protected boolean onStateChange(int[] state) {
 int newColor = mBorderColor.getColorForState(state, 0);
 if (mBorderPaint.getColor() != newColor) {
  mBorderPaint.setColor(newColor);
  return true;
 } else {
  return super.onStateChange(state);
 }
}

代码示例来源:origin: sealtalk/sealtalk-android

@Override
protected boolean onStateChange(int[] state) {
  int newColor = mBorderColor.getColorForState(state, 0);
  if (mBorderPaint.getColor() != newColor) {
    mBorderPaint.setColor(newColor);
    return true;
  } else {
    return super.onStateChange(state);
  }
}

代码示例来源:origin: GuoFeilong/BehivorDemo

@Override
protected boolean onStateChange(int[] state) {
  int newColor = mBorderColor.getColorForState(state, 0);
  if (mBorderPaint.getColor() != newColor) {
    mBorderPaint.setColor(newColor);
    return true;
  } else {
    return super.onStateChange(state);
  }
}

代码示例来源:origin: AlexMofer/ProjectX

@Override
protected boolean onStateChange(int[] state) {
  if (mItems.isEmpty())
    return super.onStateChange(state);
  boolean result = false;
  for (ChildDrawable child : mItems) {
    if (child.getDrawable().setState(state))
      result = true;
  }
  return result;
}

代码示例来源:origin: johnkil/Print

@Override
protected boolean onStateChange(int[] state) {
  if (mIconColor != null && mIconColor.isStateful()) {
    updateIconColors();
    invalidateSelf();
  }
  return super.onStateChange(state);
}

代码示例来源:origin: com.albedinsky.android/ui

/**
 */
@Override
protected boolean onStateChange(int[] state) {
  boolean appearanceChange = false;
  if (mProgressState.progressTint != null && mProgressState.progressTintMode != null) {
    this.mProgressTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.progressTint, mProgressState.progressTintMode
    );
    appearanceChange = true;
  }
  if (mProgressState.indeterminateTint != null && mProgressState.indeterminateTintMode != null) {
    this.mIndeterminateTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.indeterminateTint, mProgressState.indeterminateTintMode
    );
    appearanceChange = true;
  }
  if (mProgressState.backgroundTint != null && mProgressState.backgroundTintMode != null) {
    this.mBackgroundTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.backgroundTint, mProgressState.backgroundTintMode
    );
    appearanceChange = true;
  }
  return super.onStateChange(state) || appearanceChange;
}

代码示例来源:origin: com.albedinsky.android/ui-graphics-progress

/**
 */
@Override
protected boolean onStateChange(int[] state) {
  boolean appearanceChange = false;
  if (mProgressState.progressTint != null && mProgressState.progressTintMode != null) {
    this.mProgressTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.progressTint, mProgressState.progressTintMode
    );
    appearanceChange = true;
  }
  if (mProgressState.indeterminateTint != null && mProgressState.indeterminateTintMode != null) {
    this.mIndeterminateTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.indeterminateTint, mProgressState.indeterminateTintMode
    );
    appearanceChange = true;
  }
  if (mProgressState.backgroundTint != null && mProgressState.backgroundTintMode != null) {
    this.mBackgroundTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.backgroundTint, mProgressState.backgroundTintMode
    );
    appearanceChange = true;
  }
  return super.onStateChange(state) || appearanceChange;
}

代码示例来源:origin: com.albedinsky.android/ui-graphics

/**
 */
@Override
protected boolean onStateChange(int[] state) {
  boolean appearanceChange = false;
  if (mProgressState.progressTint != null && mProgressState.progressTintMode != null) {
    this.mProgressTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.progressTint, mProgressState.progressTintMode
    );
    appearanceChange = true;
  }
  if (mProgressState.indeterminateTint != null && mProgressState.indeterminateTintMode != null) {
    this.mIndeterminateTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.indeterminateTint, mProgressState.indeterminateTintMode
    );
    appearanceChange = true;
  }
  if (mProgressState.backgroundTint != null && mProgressState.backgroundTintMode != null) {
    this.mBackgroundTintFilter = TintDrawable.createTintFilter(
        this, mProgressState.backgroundTint, mProgressState.backgroundTintMode
    );
    appearanceChange = true;
  }
  return super.onStateChange(state) || appearanceChange;
}

相关文章