Check Mobile App
Read now
Start a Project

Image filtration with motion layout


Image filtration with motion layout

In this blog, we are going to learn some cool features of motion layout. Image filtration is one of them.


Motion Layout is a new class available in the ConstraintLayout 2.0 library. By using this class we can manage motion and widget animation in their application.

First of all, we have to implement dependency.

Implement this in your build.greadle (app) file.

Lets’s start some code:-

Now open your layout file in my case it is activity_main.xml.

In this layout file, We have MotionLayout as a view group and ImageFilterView as a child view. To perform Image filtration we need to use ImageFilterView.

In this layout file, we use layoutDescription attribute and parse a layout file motion demo_motion in it. Because layoutDesciption holds a reference of your motion_scene layout file.

This is the file that defines the type of motion/animation we want and what the starting/ending constraints are.

Here we defined a Transition (the animation) with duration & a start/endpoint to the layouts. And also a swipe Trigger on the image (with up direction) — which adds interactivity.

Specifying the saturation can be done simply by using a CustomAttribute:

Therefore we define saturation values 1 and 0 to get the filter effect.

As a result of saturation manipulation, we get a filter effect on our image.

We define two ConstraintSet children in our xml. Start and end positions of that image.

Finally, we have achieved Image filtration with motion layout.


. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.


When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

Michael Urresta

Michael Urresta

Talk to Sales


Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home