簡體   English   中英

啟動另一個活動時為活動制作動畫

[英]Animating an activity when starting another activity

我的應用程序中有活動。 活動是可見的。當我想回到主屏幕時,我想對活動上的活動進行動畫處理(fade_out)。 我已經嘗試了以下代碼,但是沒有用。

來自活動

   @Override
    public void onBackPressed() {
        super.onBackPressed();
        gotoHome();
        overridePendingTransition(android.R.animator.fade_out,android.R.animator.fade_in);
    }

    private void gotoHome() {
        Intent startHomescreen = new Intent(Intent.ACTION_MAIN);
        startHomescreen.addCategory(Intent.CATEGORY_HOME);
        startHomescreen.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(startHomescreen);
    }

從啟動器活動啟動活動A時,我將以下標志添加到意圖中

Intent.FLAG_ACTIVITY_NO_ANIMATION

我也嘗試過不使用上面的標志。

有人可以告訴我我在哪里錯地方或建議我任何有幫助的地方嗎?

活動A:

startActivity(new Intent(A.this, B.class));
            finish();
            overridePendingTransition(R.animator.enter_slidein,R.animator.exit_slideout);

活動B:

@Override
public void onBackPressed() {
    startActivity(new Intent(B.this, A.class));
    finish(); 
    overridePendingTransition(R.animator.enter_slidein,R.animator.exit_slideout);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM