Whoever want more blurry effect, please check the following class I have used.
Note the for loop -> more time you loop more you get blurred. (For above question ImageView can be use inside RelativeLayout)
public class BlurTransformation implements Transformation {
RenderScript rs;
public BlurTransformation(Context context) {
super();
rs = RenderScript.create(context);
}
@Override
public Bitmap transform(Bitmap bitmap) {
// Create another bitmap that will hold the results of the filter.
Bitmap blurredBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
for (int i = 0; i < 10; i++) {
// Allocate memory for Renderscript to work with
Allocation input = Allocation.createFromBitmap(rs, blurredBitmap, Allocation.MipmapControl.MIPMAP_FULL, Allocation.USAGE_SHARED);
Allocation output = Allocation.createTyped(rs, input.getType());
// Load up an instance of the specific script that we want to use.
ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
script.setInput(input);
// Set the blur radius
script.setRadius(25);
// Start the ScriptIntrinisicBlur
script.forEach(output);
// Copy the output to the blurred bitmap
output.copyTo(blurredBitmap);
}
bitmap.recycle();
return blurredBitmap;
}
@Override
public String key() {
return "blur";
}
}
Using this with picasso:
List<Transformation> transformations = new ArrayList<>();
transformations.add(new BlurTransformation(mContext));
Picasso.get().load(Uri.parse(url))
.tag(mContext)
.placeholder(defaultresource)
.transform(transformations)
.placeholder(defaultresource)
.into(imageview, new Callback() {
@Override
public void onSuccess() { }
@Override
public void onError(Exception e) {
}
});
Hope this will help you.