1

默认情况下,新活动从右侧进入,并从右侧退出。我想让它进入和退出表单底部,但我尽力了,我只能让它从底部出来,从右边退出,这是我的代码。我需要一些帮助,谢谢。

private void show() {
        Intent intent = new Intent();
        intent.setClass(this, PromotionActivity.class);
        startActivity(intent);
        overridePendingTransition(R.anim.slide_bottom_enter,R.anim.slide_bottom_exit); 
    }

slide_bottom_exit.xml:

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

R.anim.slide_bottom_enter.xml:

<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fromYDelta="200%p"
    android:toYDelta="0%p" 
    android:duration="@android:integer/config_mediumAnimTime">
</translate>
4

1 回答 1

2

try this code to make transitions and then tell me:

  • when you want to appear your activity from bottom

    overridePendingTransition(R.anim.top_to_bottom_in,R.anim.top_to_bottom_out);
    
  • top_to_bottom_in

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

        <?xml version="1.0" encoding="utf-8"?>
        <translate xmlns:android="http://schemas.android.com/apk/res/android"
        android:duration="1000"
        android:fromYDelta="0%p"
        android:toYDelta="100%p" />
    
  • when you want to make exit you activity

    overridePendingTransition(R.anim.bottom_to_top_in, R.anim.bottom_to_top_out);
    
    -bottom_to_top_in
    
    <?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromYDelta="100%p"
    android:toYDelta="0%p" />
    
  • bottom_to_top_out

    <?xml version="1.0" encoding="utf-8"?>
    <translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromYDelta="0%p"
    android:toYDelta="-100%p" />
    
于 2013-01-14T06:09:26.890 回答