How to blur background images in Android –

Development issue/problem:

What is the best way to blur the background images as shown below? I’ve seen some codes and libraries, but they’re a few years old, or like the BlurBehind library, but it doesn’t have the same effect. Thank you in advance.

How can I solve this problem?

Solution 1:

The easiest way is to use a library. Visit:

With the library is all you have to do:

.color.argb(66, 255, 255, 0))
.on(rootView) ;

Solution 2:

This is a simple way to efficiently blur images using the Android RenderScript, which I found in this article.

  1. Create a class called BlurBuilder.

public class BlurBuilder {
private static end fleet BITMAP_SCALE = 0,4f ;
private static end fleet BLUR_RADIUS = 7,5f ;

public static bitmap blur (context, bitmap image) {
int width = Math.round(image.getWidth() * BITMAP_SCALE) ;
int height = Math.round(image.getHeight() * BITMAP_SCALE) ;

Bitmap inputBitmap = Bitmap.createScaledBitmap (image, width, height, scythe);
Bitmap outputBitmap = Bitmap.createBitmap(inputBitmap) ;

RenderScript rs = RenderScript.create(context);
ScriptIntrinsicBlur deIntrinsicBlur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
Allocation tmpIn = Allocation.createFromBitmap(rs, inputBitmap);
Allocation tmpOut = Allocation.createFromBitmap(rs, outputBitmap);
tmpOut.copyTo(outputBitmap) ;

inverse outputCalculation cards;

  1. Copy any image to the drawings folder
  2. Use the BlurBuilder in your activities as follows:

protected void onCreate(Bundle savedInstanceState) {

mContainerView = (LinearLayout) findViewById(;
Bitmap originalBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.background);
Bitmap blurredBitmap = BlurBuilder.blurder( this, originalBitmap);
mContainerView.setBackground(new BitmapDrawable(getResources(), blurredBitmap)

  1. Renderscript is included in the v8 support, so you can get an answer before api 8. To enable it with gradle, add these lines to your gradle file (of this answer)

defaultConfig {

renderscriptTargetApi *Your target api*
renderscriptSupportModeEnabled true

  1. Result

Solution 3:

You can make use of

.apply(bitmapTransform(new BlurTransform(22))
.in((ImageView) view.findViewById(

Solution 4:

The easiest way to do this is described below,


.load(your path)
.override(15, 15) // (modify if necessary)
.in(image.score) ;

Otherwise you can follow the code below….


Create a class (code below).

The BlurTransformation public class extends BitmapTransformation {

RenderScript rs private ;

public BlurTransformation(Context) {
super( context) ;

rs = RenderScript.create( context);

@ Oberried
protected bitmap conversion (BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
Bitmap blurredBitmap = toTransform.copy( Bitmap.Config.ARGB_8888, true) ;

// assign memory for renderscript
Allocation input = Allocation.createFromBitmap(
) ;
Allocation output = Allocation.createTyped(rs, input.getType())

// Load a copy of the specific script we want to use.
ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)) ;
script.setInput(input) ;

// Set the blurry radius

// Run ScriptIntrinisicBlur

// Copy output to blurred bitmap
output.copyTo(blurredBitmap) ;

toTransform.recycle() ;

invert blurBitmap;

public String getId() {
return blur;

2 Drag the image to ImageView.

For example:

.transform(new BlurTransformation(this)))
.to(ivBackground) ;

Solution No 5:

You can apply a black background color to the display and set the alpha value of the display to 0.7 or another value if necessary.

Solution No 6:

It may not be the most efficient solution, but I had to use it because the raccoon/vault library didn’t work for me. This can be useful if you have fuzzy animations:

1- You must have 2 versions of the picture, the normal and the blurred one you do with photoshop or something like that.

2- Adjust the images in the xml, then one of the images will be visible and it will be the top one.

3 – Adjust the damping animation at the top:

fadeOut last animation output = new AlphaAnimation(1, 0) ;
fadeOut.setInterpolator(new AccelerateInterpolator()) ;
fadeOut.setDuration(1000) ;

fadeOut.setAnimationListener(new Animation.AnimationListener() {
public void onAnimationStart(AnimationStart)) {}

public void onAnimationEnd(Animation) {upperone.setVisibility(View.GONE);}

public void onAnimationRepeat(Animation {}
}) ;

upperone.startAnimation(fadeOut) ;

Solution No 7:

Try it under the code…
Paste this code into On Create… .

If (android.os.Build.VERSION.SDK_INT > 9) {
StrictMode.ThreadPolicy policy =
new StrictMode.ThreadPolicy.Builder().allowAll().build();
// Picasso.with(getContext()).load(Url).into(img_profile) ;
// Picasso.with(getContext())).load(Url).into(img_c_profile) ;

bitmap=getBitmapFromURL(Url) ;
blur bitmap = blurRenderScript(bitmap, 12);//second parameter corresponds to the radius
img_profile.setImageBitmap(blur) ;

Make subordinate methods… Just copy the past…

public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream input = connection.getInputStream();
bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (IOException e) {
//exclude log
return null;
private Bitmap blurRenderScript(Bitmap smallBitmap, intradius) {

try {
smallBitmap = RGB565toARGB888(smallBitmap);
} catch (Exception e) {

Bitmap = Bitmap.createBitmap(
smallBitmap.getWidth(), smallBitmap.getHeight(),
Bitmap.Config.ARGB_8888) ;

RenderScript renderScript = RenderScript.create(getActivity()) ;

Allocation blurInput = Allocation.createFromBitmap(renderScript, smallBitmap) ;
Allocation blurOutput = Allocation.createFromBitmap(renderScript, bitmap) ;

ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(renderScript,
blur.setRadius(radius); // the radius must be 0 < r <= 25

blurOutput.copyTo(bitmap) ;
renderScript.destroy() ;

Reverse map ;


private Bitmap RGB565àARGB888(Bitmap img) throws the exception [
int numPixels = img.getWidth() * img.getHeight() ;
int[] pixels = new int [numPixels] ;

/Get JPEG Pixel/ Each int is a color value for a pixel.
img.getPixels (pixel, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight())

/Create a bitmap in a suitable format.
Result of the bitmap = Bitmap.createBitmap(img.getWidth(), img.getHeight(), Bitmap.Config.ARGB_8888) ;

//Set the RGB pixels.
result.setPixels (pixels, 0, result.getWidth(), 0, 0, result.getWidth(), result.getHeight());
return result;

Solution No 8:

you can use Glide to download and convert to a blurred image,
1) for a single view,

val requestOptions = RequestOptions()
requestOptions.transform(BlurTransformation(50)) // 0-100

2) If you use an adapter to load an image into an element, you must write your code into the if-else block, otherwise all your images will become blurred.

val requestOptions = RequestOptions()
.load(imageUrl).into(view )
fall requestOptions = RequestOptions()
Glide.with(applicationContext).setDefaultRequestOptions(requestOptions).load(imageUrl).into(view )

Solution No 9:

This answer may be very late, but I hope it helps someone.

  1. You can use external libraries such as RenderScript/Blurry/etc.
  2. If you don’t want to use third-party libraries, you can do the following with alpha (setting alpha to 0 means completely blurred and 1 means the same as the existing libraries).

Note (If using point 2) : If you put alpha in the background, the whole layout becomes blurred. To prevent this, create a new xml with the rendering and set the alpha here to 0.5 (or any value) and use this rendered name (filename) as background.

For example, use B. as shown below (e.g. file name bgndblur.xml) :

Use the following diagram:

I hope this helps.

Solution No 10:

You can quickly create a blurred effect by doing the following.

// Add this to the build.gradle //.

Compile com.github.jgabrielfreitas:BlurImageView:1.0.1 .

// Add to XML

/ Add this to the java

Import com.jgabrielfreitas.core.BlueImageView ;

// Under the social class, the *name of the activity.

Delete myBlurImage ;


myBlurImage = (ImageView) findViewById(

I hope that helps somebody.

Good luck!

Related Tags:

how to blur background in photo,blurred background photo editor app,blur background app android,photo blur app android,how to blur background of photo already taken,how to take pictures with blurred background on android,how to make linearlayout background blur in android,how to blur background image in android xml,blur transparent background android