How to animate a view to hide under another view, and then animate from that view

I have two kinds of grids for which I would like to create a custom animation. Imagine this layout:

  ___________________________________________
 |  |
 |  |
 |  TOP Grid |
 |  |
 | _________________________________________ |
 |  |
 |  |
 |  BOTTOM |
 |  Grid |
 |  |
 | _________________________________________ |

The lower grid will “extend” and “slide” behind the upper grid. I believe that I should use translational animation. How to find out fromX and fromY? I thought I have both views in the layout, and then set the animation as RelativeToParent.

Is this the right approach? If you know somewhere, I can find the source code for this function, I would really appreciate it. Thanks,

+6
source share
1 answer

Try the slide-out and slide-in animations.

slide-top-in.xml

  <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator" android:fromYDelta="0" android:toYDelta="-100%p" android:duration="1000" /> </set> 

slide-top-out.xml

 <translate xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/linear_interpolator" android:fromYDelta="-100%p" android:toYDelta="0" android:duration="1000" /> 
0
source

Source: https://habr.com/ru/post/911118/


All Articles