2016年10月1日 星期六
Picasso:how to add a Reflect effect to the image
at the into function,add a callback
private void setImageUrl(ImageView imageView, String url) {
Picasso.with(getContext())
.load(url)
.centerCrop().fit()
.transform(new EffectTransformation())
.into(imageView, new Callback() {
@Override
public void onSuccess() {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (imageVBackground.getDrawable() != null) {
Bitmap bmp = ((BitmapDrawable) (imageVBackground.getDrawable())).getBitmap();
int bmpWidth = bmp.getWidth();
int bmpHeight = bmp.getHeight();
Bitmap b = Bitmap.createBitmap(bmp, 0, bmpHeight * 5 / 6, bmpWidth, bmpHeight / 6, null, false);
Bitmap newBitmap = addGradient(b);
ivMirror.setImageBitmap(newBitmap);
// ivMirror.setAlpha(0.1f);
}
}
}, 300);
}
@Override
public void onError() {
}
});
}