如何为视图设置动画以隐藏在另一个视图下方,然后从该视图中设置动画

时间:2012-03-19 17:13:59

标签: android android-layout android-animation android-gridview

我有两个网格视图,我想为其创建自定义动画。 想象一下这个布局:

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

底部网格将在顶部网格后面“滑出”和“滑动”。我想我应该使用翻译动画。我如何找到fromX&从Y值?我以为我可以同时在布局中查看,然后将动画设置为RelativeToParent。

这是正确的方法吗?如果您知道任何地方我可以找到此功能的源代码,我将非常感激。谢谢,

1 个答案:

答案 0 :(得分:0)

试试这个slide-out& slide-in动画。

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" />
相关问题