简体   繁体   中英

Android DrawerLayout blur background

I would like to blur the background of the content pane when the DrawerLayout is open. I noticed that there is the ability to change the dim color by setting setScrimColor but I would like to blur the background. Is there a way to achieve this?

The process involves the following stages:

  • Get a snapshot of the whole drawer layout.

  • Crop it to the exact size of your menu.

  • Downscale it quite a bit (a factor of 8 is pretty good).

  • Blur that image.

  • Have a custom view that displays part of an image right behind of where your menu will appear.

    • As you slide the drawer show a larger part of that image.

Please refer this answer

Blur background of Navigation Drawer

Or you can use one of these libraries

EtsyBlur

BlurNavigationDrawer

BlurEffectForAndroidDesign

Check out this library: Blurry . it takes a View or a Bitmap , blurs it and casts it to a ViewGroup or an ImageView . So just run Blurry.with(context).capture(parentView).into(parentView); whenever the drawer is opened. Where parentView is the container that holds everything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM