5

私はそれがインターネット上のいくつかの例であることを知っています。また、ここStackoverflowでも多くの例を見つけましたが、信じられないかもしれませんが、どれも私が必要とするものを提供していません. 私も数回前に同様の質問をしましたが、この問題に再び立ち往生しています。基本的には同じ質問ですが、反対方向です。好きなアニメーションを作成できますActivity Bが、ここでの問題はActivity A、いくつかのシナリオでのみアニメーション化できることです。基本的にこの組み合わせでのみActivityAプレイします。enter_left

overridePendingTransition(R.anim.enter_from_right, R.anim.exit_on_left);

私がやりたいのは、画面上で動かないようにしながら、Activity Aどちらかだけをアニメーション化(移動)することです。常に上に描画する必要があります(スライドメニューとして、 でこれを行うことができます)。上記のスニペットでうまくいくと本当に思っていました:startActivity()onBackPressed()Activity BActivity AActivity B

Intent intent = new Intent(ActivityA.this, ActivityB.class);
                startActivityForResult(intent, 500);
                overridePendingTransition(R.anim.stay_still, R.anim.exit_on_left);

ただし、これはアニメーションを再生しませんが、

//this is the animation for onBackPressed()
@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        overridePendingTransition(R.anim.enter_from_left, 0);
    }

Activity A私が望むようにアニメーション化しますが、Activity B突然画面から消えて、私はとどまりたいです (設定(R.anim.enter_from_left, R.anim.stay_still)は何もしません)。

必要な 5 つのアニメーションをすべて用意しました。

enter_from_left

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<translate
    android:duration="500"
    android:fromXDelta="-100%"
    android:toXDelta="0%" />
</set>

exit_on_left

<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >

<translate
    android:duration="500"
    android:fromXDelta="0%"
    android:toXDelta="-100%" />
</set>

enter_from_right

    <set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <translate
        android:duration="500"
        android:fromXDelta="100%"
        android:toXDelta="0%" />
   </set>

exit_on_right

    <set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <translate
        android:duration="500"
        android:fromXDelta="0%"
        android:toXDelta="100%" />
   </set>

じっとしている

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false" >

    <translate
        android:duration="500"
        android:fromXDelta="0%"
        android:toXDelta="0%" />
</set>

私は多くの組み合わせを試しましたが、どれもうまくいきませんでした。このアニメーションが可能かどうか、またこの方法で可能かどうか教えてください。やりたいことをより明確にするために、画像を投稿します。

したがって、最初のステップ: onは左側から画面を離れ、移動中はstartActivity()すでに「そこに」、「その下に」いる必要があります。ActivityAActivity B

ここに画像の説明を入力

そして、onBackPressed() Acyivity B「戻ってくる」はずで、画面左側から入り、ActivityB動かないものを重ねます。

ここに画像の説明を入力

4

5 に答える 5

0

I could find that the next one works very nice with fragments fragmentTransaction.setCustomAnimations(R.anim.stay_still,R.anim.exit_on_left);
while overridePendingTransition(R.anim.stay_still, R.anim.exit_on_left); does not work with activity.

On the other hand the reverse,

overridePendingTransition(R.anim.enter_from_left, 0); or fragmentTransaction.setCustomAnimations(R.anim.enter_from_left, 0);

does not work with activity neither with fragments. The most close approach that works was transaction.setCustomAnimations(R.anim.stay_still,R.anim.exit_on_left, R.anim.enter_from_left,R.anim.exit_on_right);

If anyone has any other solution, I'm still waiting to hear it and it will be appreciated.

于 2013-11-07T14:58:09.363 に答える
0

この組み合わせを試したかどうかはわかりませんが、うまくいくはずです.-

startActivityForResult(intent, 500);
overridePendingTransition(R.anim.enter_from_left, R.anim.stay_still);
于 2013-11-04T23:30:46.160 に答える