ScrimViewpublic class ScrimView extends android.view.View A view which can draw a scrim |
Fields Summary |
---|
private int | mScrimColor | private boolean | mIsEmpty | private boolean | mDrawAsSrc | private float | mViewAlpha | private android.animation.ValueAnimator | mAlphaAnimator | private ValueAnimator.AnimatorUpdateListener | mAlphaUpdateListener | private android.animation.AnimatorListenerAdapter | mClearAnimatorListener |
Constructors Summary |
---|
public ScrimView(android.content.Context context)
this(context, null);
| public ScrimView(android.content.Context context, android.util.AttributeSet attrs)
this(context, attrs, 0);
| public ScrimView(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)
this(context, attrs, defStyleAttr, 0);
| public ScrimView(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)
super(context, attrs, defStyleAttr, defStyleRes);
|
Methods Summary |
---|
public void | animateViewAlpha(float alpha, long durationOut, android.view.animation.Interpolator interpolator)
if (mAlphaAnimator != null) {
mAlphaAnimator.cancel();
}
mAlphaAnimator = ValueAnimator.ofFloat(mViewAlpha, alpha);
mAlphaAnimator.addUpdateListener(mAlphaUpdateListener);
mAlphaAnimator.addListener(mClearAnimatorListener);
mAlphaAnimator.setInterpolator(interpolator);
mAlphaAnimator.setDuration(durationOut);
mAlphaAnimator.start();
| public int | getScrimColor()
return mScrimColor;
| public boolean | hasOverlappingRendering()
return false;
| protected void | onDraw(android.graphics.Canvas canvas)
if (mDrawAsSrc || (!mIsEmpty && mViewAlpha > 0f)) {
PorterDuff.Mode mode = mDrawAsSrc ? PorterDuff.Mode.SRC : PorterDuff.Mode.SRC_OVER;
int color = mScrimColor;
color = Color.argb((int) (Color.alpha(color) * mViewAlpha), Color.red(color),
Color.green(color), Color.blue(color));
canvas.drawColor(color, mode);
}
| public void | setDrawAsSrc(boolean asSrc)
mDrawAsSrc = asSrc;
invalidate();
| public void | setScrimColor(int color)
if (color != mScrimColor) {
mIsEmpty = Color.alpha(color) == 0;
mScrimColor = color;
invalidate();
}
| public void | setViewAlpha(float alpha)
if (mAlphaAnimator != null) {
mAlphaAnimator.cancel();
}
mViewAlpha = alpha;
invalidate();
|
|