How to blur imageview in android

后端 未结 10 1989
南笙
南笙 2020-12-05 10:54

I have an imageview and i set Image Resources programmatically like this:

int resourceId = getResources().getIdentifier(\"imagename\", \"drawable\", \"mypack         


        
10条回答
  •  粉色の甜心
    2020-12-05 11:51

    You can use RenderScript to accomblish that as explained here or you can use the stackblur library to make a blurring effect in your image.

    Usage of the stackblur library:

    int resourceId = getResources().getIdentifier("imagename", "drawable", "mypackage");
    // get bitmap from resource id
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
    StackBlurManager stackBlurManager = new StackBlurManager(bitmap);
    // process the image using a certain radius
    stackBlurManager.process(progress*4);
    // obtain the image and load it into an ImageView or any other component
    imgLock.setImageBitmap(stackBlurManager.returnBlurredImage());
    

提交回复
热议问题