从上到下或从上到下淡入/淡出视图,而无需使用“缩放”平移或缩小视图

时间:2018-10-23 03:14:18

标签: android animation android-animation

我正在尝试实现使视图从上到下或从上到下淡化的动画。视图在消失时应保持其比例和位置。因此,我无法使用平移或缩放比例(缩放比例会缩小视图。

任何人都可以帮助我实现这一目标吗?

1 个答案:

答案 0 :(得分:0)

也许overridePendingTransition会有所帮助?

Intent newActivity = new Intent(getApplicationContext(), activity.class);
startActivity(newActivity);
this.overridePendingTransition(R.anim.swipe_left_enter, R.anim.swipe_left_exit);

和动画刷卡可能类似于:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:fromXScale="0.0"
        android:fromYScale="1.0"
        android:pivotX="100%"
        android:pivotY="50%"
        android:toXScale="1.0"
        android:toYScale="1.0"
        android:duration="100"
        android:fillAfter="true"/>
</set>

这是一个滑动示例,但也可以用作淡入淡出动画。

P.S。我忘了提到您应该实施

class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
   @Override
   public boolean onFling(MotionEvent event1, MotionEvent event2,
                            float velocityX, float velocityY) {
        // your code here
   }
 }

onFling

相关问题