Issue
I want to make an animation in RecyclerView
which requires a child to have a bigger z-index than another child. However, when I used the bringToFront
method in ViewGroup
it did not work.
Is there any way to bring a child to front in RecyclerView
?
Solution
Order of children is controlled by the LayoutManager. Built in LayoutManagers have their own strict child order for performance reasons.
Current implementation of bringToFront simply moves the child to the end of children list which won't play nice with existing LayoutManagers.
If you are targeting Lollipop, you can use setElevation method. To target older platforms, you'll need a custom LayoutManager that does not rely on order of children.
Answered By - yigit
Answer Checked By - Senaida (JavaFixing Volunteer)