Skip to content

Instantly share code, notes, and snippets.

@lithid
Created September 1, 2013 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lithid/6405433 to your computer and use it in GitHub Desktop.
Save lithid/6405433 to your computer and use it in GitHub Desktop.
Shown to show transparency
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
boolean result;
final int save = canvas.save(Canvas.CLIP_SAVE_FLAG);
boolean drawScrim = false;
boolean mDrawBehind = true;
if (!mDrawBehind && mCanSlide && !lp.slideable && mSlideableView != null) {
// Clip against the slider; no sense drawing what will immediately be covered.
canvas.getClipBounds(mTmpRect);
mTmpRect.bottom = Math.min(mTmpRect.bottom, mSlideableView.getTop());
canvas.clipRect(mTmpRect);
if (mSlideOffset < 1) {
drawScrim = true;
}
}
result = super.drawChild(canvas, child, drawingTime);
canvas.restoreToCount(save);
if (drawScrim) {
final int baseAlpha = (mCoveredFadeColor & 0xff000000) >>> 24;
final int imag = (int) (baseAlpha * (1 - mSlideOffset));
final int color = imag << 24 | (mCoveredFadeColor & 0xffffff);
mCoveredFadePaint.setColor(color);
canvas.drawRect(mTmpRect, mCoveredFadePaint);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment