Пример #1
0
  @Override
  protected boolean onStateChange(int[] state) {
    mEnable = ViewUtil.hasState(state, android.R.attr.state_enabled);
    int color = mColorStateList.getColorForState(state, mCurColor);

    if (mCurColor != color) {
      if (!mInEditMode && mAnimEnable && mEnable && mAnimDuration > 0) {
        mPrevColor = isRunning() ? mPrevColor : mCurColor;
        mCurColor = color;
        start();
      } else {
        mPrevColor = color;
        mCurColor = color;
        invalidateSelf();
      }
      return true;
    } else if (!isRunning()) mPrevColor = color;

    return false;
  }
Пример #2
0
 public void applyStyle(int resId) {
   ViewUtil.applyStyle(this, resId);
   applyStyle(getContext(), null, 0, resId);
 }