【问题标题】:How to transition the activity from top to bottom and viceversa?如何将活动从上到下转换,反之亦然?
【发布时间】:2012-03-13 12:00:32
【问题描述】:

谁能告诉我如何在 Android 中将活动从上到下转换,也许可以举个例子?

【问题讨论】:

  • 是的..我在进入活动时需要从上到下的动画。

标签: android-animation


【解决方案1】:

在 res/anim/slide_in_up.xml 中定义一个动画:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="100%p" android:toYDelta="0%p"
    android:duration="@android:integer/config_longAnimTime"/>

另一个在 res/anim/slide_out_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromYDelta="0%p" android:toYDelta="-100%p"
    android:duration="@android:integer/config_longAnimTime"/>

然后在调用 startActivity 之后应用这些:

Intent i2 = new Intent(main.this, test.class);
startActivity(i2);
overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );

【讨论】:

  • 这个带有一些解释的答案会很棒。只有代码不是人们寻找的东西。如果他们有一些解释,我们(初学者)会得到一些丰富的东西。
猜你喜欢
  • 2016-03-29
  • 2017-07-08
  • 2011-07-27
  • 2021-06-10
  • 2012-03-24
  • 2018-06-28
  • 2010-12-04
  • 2012-01-15
相关资源
最近更新 更多