protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int height = getHeight();
int width = getWidth();
setDrawingCacheEnabled(true);
Bitmap originalImage = Bitmap.createBitmap(getDrawingCache());//这一句
Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, height/5, width, height/2, mMatrix, false);//还有这一句
canvas.drawBitmap(reflectionImage, 0, height/3f, null);
if(mPaint == null) {
mPaint = new Paint();
LinearGradient shader = new LinearGradient(0, height/2, 0,
height, 0x7fffffff, 0x0fffffff, TileMode.CLAMP);
mPaint.setShader(shader);
mPaint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
}
canvas.drawRect(0, height/2f, width, height, mPaint);
}