I would like to draw a fading edge at somewhere on my view programmatically, I just copied the build in fading edge feature of android view system, but it can't work, any suggestions?
mShaderPaint = new Paint();
mMatrix = new Matrix();
mShader = new LinearGradient(0, 0, 0, 1, 0xFF000000, 0, Shader.TileMode.CLAMP);
mShaderPaint.setShader(mShader);
mShaderPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
mFadingRect = new RectF();
// in dispatchDraw
final int sc = canvas.getSaveCount();
final int flags = Canvas.HAS_ALPHA_LAYER_SAVE_FLAG;
canvas.saveLayer(mFadingRect, null, flags);
mMatrix.setScale(1, (float)(.8 * mFadingEdgeLength));
mMatrix.postRotate(180);
mMatrix.postTranslate(mFadingRect.left, mFadingRect.bottom);
mShader.setLocalMatrix(mMatrix);
canvas.drawRect(mFadingRect, mShaderPaint);