简体   繁体   English

Android活动过渡动画仅适用于被叫活动

[英]Android activity transition animation for called activity only

I'm attempting to create an android activity transition where activity a calls activity b, I need activity b to slide in from the right of the screen when called and slide out of the right side of the screen when destroyed, during both transitions I need activity a to stay in place and not animate whatsoever. 我正在尝试创建一个Android活动过渡,其中活动a调用活动b,我需要活动b在调用时从屏幕的右侧滑入并在销毁时从屏幕的右侧滑出,在两次过渡期间都需要活动a以保持原位,并且不进行任何动画处理。

I've searched for this and all animations I find are making activity a animate as well as I am trying to avoid this, any help will go a long way thanks! 我已经搜索了此动画,并且发现所有动画都使活动具有动画效果,并且我正努力避免这种情况,任何帮助都将大有帮助!

intent from calling activity: 通话活动的意图:

 public void searchButtonClick(View view) {

    Intent intent = new Intent(this, SearchActivity.class);
    startActivity(intent);

    overridePendingTransition(R.anim.animate1, R.anim.animate2);

}

animate1.xml animate1.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate android:fromXDelta="0%"
    android:toXDelta="100%"
    android:duration="@android:integer/config_mediumAnimTime" />

</set>

animate2.xml animate2.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">

<translate
    android:fromXDelta="0%" android:toXDelta="100%"
    android:fromYDelta="0%" android:toYDelta="0%"
    android:duration="700" />

</set>

Add below line 在行下方添加

overridePendingTransition(R.anim.animate1, R.anim.animate2);

in your onStart() or onCreate() of SearchActivity.class SearchActivity.class onStart()onCreate()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM