【问题标题】:How to animate a View to hide underneath another view, and then animate from that View如何为视图设置动画以隐藏在另一个视图下方,然后从该视图设置动画
【发布时间】:2012-03-19 17:13:58
【问题描述】:

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

___________________________________________ | | | | |顶部网格 | | | |_________________________________________| | | | | |底部 | |网格 | | | |_________________________________________|

底部网格将“滑出”并“滑”到顶部网格后面。我想我应该使用翻译动画。如何找出 fromX 和 fromY 值?我以为我可以在一个布局中同时拥有两个视图,然后将动画设置为 RelativeToParent。

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

【问题讨论】:

  • 你有什么解决办法吗?我也试着找出来。目前底部网格将在动画时覆盖顶部网格。他们在 LinearLayout

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


【解决方案1】:

试试这个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" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多