How can I add a blur effect on a drawable image placed in the image view object of a layout, using xml not Java? I want to code this blur effect in XML.
You can use the new Resource Manager tab Click on the + sign and select Import Drawables . From here, you can select multiple folders/files and it will handle everything for you. Click the import button and the images will be automatically imported to the correct folder.
BlurView can be used as a regular FrameLayout. It blurs its underlying content and draws it as a background for its children. BlurView redraws its blurred content when changes in view hierarchy are detected (draw() called). It honors its position and size changes, including view animation and property animation.
It is not currently possible to produce a blur effect within the layout XML of an Android application.
However, it is possible through the use of Java. There are a number of techniques available to do this (see here for a recent guide on how to do this effectively). Usually either Renderscript
or the re-scaling of the image is used to generate a blur of the image.
Edit:
It may now be possible to achieve a blur solely by adding an XML property through the use of a custom data binding adapter. Check out the data binding library for more on how to create an adapter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With