Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the blur level of a view background

To set the transparency level of a view background we use

mView.getBackground().setAlpha(mViewTransparencyLvl);

How to set the blur level of a view background?

Knowing that the background is a shape drawable not an image. Knowing that the user controls the blur degree. Knowing that this view is over part of another view.

enter image description here

like image 401
Jack Avatar asked Apr 15 '18 12:04

Jack


1 Answers

Android doesn't provide this functionality for UI elements as iOS does. It's not part of the UI rendering engine and to obtain these kind of effects you need to use third-party libraries which will essentially take a snapshot of the drawing cache, reduce its size for a faster processing and then put the generated bitmap into a view.

Here are some example libraries:

  • BlurrView
  • Blurry

Please bear in mind that this will have a serious performance hit on mid-low end phones.

like image 81
Cristian Holdunu Avatar answered Oct 13 '22 02:10

Cristian Holdunu