How to put an ImageView above a MenuItem so it can be moved with ObjectAnimator
Asked Answered
I

0

6

I am currently trying to achieve a SearchView animation similar to the one in Plaid, however I am encountering a problem as in my case, the app shall stay in the same activity and thus I need to use ObjectAnimator to move the search icon over to the back icon. The Animated Vector Drawable is working fine.

I did try to ways of realizing the movement so far: First, I put the Animated Vector Drawable inside the MenuItem. If I tell ObjectAnimator to move the item over to the left though, it gets hidden (probably behind some toolbar element) after the animation has started. As this did not work out, I decided to try and put an ImageButton above the toolbar with a FrameLayout and tell this ImageButton to move over to the right while also starting the AVD animation, which works. My problem is now that if I try to get the MenuItems X and Y to place the ImageButton above the MenuItem, my app crashes with a NullPointerException stating X and Y can't be found.

Do you see a solution to my problem? The animation I want to achieve is that the search drawable goes over to the hamburger icon (which is getting a search icon when Search gets pressed as the search view gets opened up).

The search menu icon and the additional icon I created which I might put above

Isla answered 15/5, 2019 at 8:43 Comment(1)
put piece of code here where app crashes .Mousetail

© 2022 - 2024 — McMap. All rights reserved.