Android, how to blur/glass/frost current activity

前端 未结 1 811
野的像风
野的像风 2020-12-04 13:36

Basically

In an activity, I have a ListView. When I select an item, an transparent activity opens as a small box. When this box appears, you can still view the previ

相关标签:
1条回答
  • 2020-12-04 14:24

    For API < 14, you could use the flag WindowManager.LayoutParams.FLAG_BLUR_BEHIND, but it's been deprecated and built-in blurring is no longer supported on higher APIs

    However, you could do this with a regular view or overlay. What you want to do is:

    • Create a Bitmap from your activity's overall layout (see here for example)
    • Blur that bitmap with whatever method you want(a few examples here)
    • Add(or unhide) a View in your layout that covers everything. Set bkg to blurred Bitmap
    • Open your dialog/transparent activity
    • When it closes, either remove the View, or setVisibility(GONE) if you'll be using it again.
    0 讨论(0)
提交回复
热议问题