Here is a code snippet to allow the behind view to fade in/out as it is opening/closing.
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
final int behindWidth = this.getBehindWidth();
// Draw the margin drawable if needed.
if (mShadowWidth > 0 && mShadowDrawable != null) {
final int left = behindWidth - mShadowWidth;
mShadowDrawable.setBounds(left, mTopPageBounds, left + mShadowWidth,
mBottomPageBounds);
mShadowDrawable.draw(canvas);
}
final float openPercent = (mScroller.getCurrX()) / (float) behindWidth;
onDrawMenuFade(canvas, openPercent, behindWidth);
}
private static final int MAXIMUM_MENU_FADE = 170;
private Paint mBehindFadePaint = new Paint();
private void onDrawMenuFade(Canvas canvas, float openPercent, int width) {
final int alpha = (int) (MAXIMUM_MENU_FADE * openPercent);
if (alpha > 0) {
mBehindFadePaint.setColor(Color.argb(alpha, 0, 0, 0));
canvas.drawRect(0, 0, width, getHeight(), mBehindFadePaint);
}
}