首页 新闻 会员 周边 捐助

Avoid object allocations during draw/layout operations (preallocate and reuse instead)

-1
悬赏园豆:5 [待解决问题]

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);
}

includecmath的主页 includecmath | 初学一级 | 园豆:194
提问于:2015-01-06 21:02
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册