How to blur background images in Android

前端 未结 10 2108
借酒劲吻你
借酒劲吻你 2020-11-30 22:12

What is the best way to blur background images like the image below? I saw some code and libraries but their are a couple of years old or like BlurBehind library, but it doe

10条回答
  •  攒了一身酷
    2020-11-30 23:09

    This might be a very late reply but I hope it helps someone.

    1. You can use third party libs such as RenderScript/Blurry/etc.
    2. If you do not want to use any third party libs, you can do the below using alpha(setting alpha to 0 means complete blur and 1 means same as existing).

    Note(If you are using point 2) : While setting alpha to the background, it will blur the whole layout. To avoid this, create a new xml containing drawable and set alpha here to 0.5 (or value of your wish) and use this drawable name (name of file) as the background.

    For example, use it as below (say file name is bgndblur.xml):

    
    

    Use the below in your layout :

    <....
     android:background="@drawable/bgndblur">
    

    Hope this helped.

提交回复
热议问题