}else{
isScrollUp = true;
float r = curY / threshold ;
ivOrange.setImageBitmap(circleBitmap(bmOrange, r * screenWidth));
}
}
});
裁剪
private Bitmap circleBitmap(Bitmap o,float radius){
Bitmap outputBm = Bitmap.createBitmap(o.getWidth(),o.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(outputBm);
final Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
final Rect rect = new Rect(0,0,o.getWidth(),o.getHeight());
canvas.drawARGB(0,0,0,0);
canvas.drawCircle(0,0,radius,paint );
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(o,rect,rect,paint);
return outputBm;
}
裁剪
private Bitmap circleBitmap(Bitmap o,float radiu