安卓:同时实现第一个活动和下一个活动的动画效果

3
我已经解决了。如果你需要帮助,这是我的电子邮件:emmets@foxmail.com。
XML布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<RelativeLayout
    android:id="@+id/newLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
</RelativeLayout>

<RelativeLayout
    android:id="@+id/oldLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
</RelativeLayout>

Java代码,需要扩展ActivityGroup:

LocalActivityManager localLocalActivityManager = getLocalActivityManager();
    paramIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    Window localWindow = localLocalActivityManager.startActivity("flag", NewActivity.class);
    localWindow.addFlags(1);
    View localView = localWindow.getDecorView();
    localView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    newLayout.addView(localView);
 dAnimation upOut = AnimationUtils.loadAnimation(this, R.anim.push_up_out);
     Animation zoomEnter = AnimationUtils.loadAnimation(this, R.anim.zoom_enter);
newLayout.startAnimation(zoomEnter);
oldLayout.startAnimation(upOut);

当动画开始时,底部显示下一个活动页面,然后第一页的动画和下一页的动画同时开始。这句话的意思是,在动画开始时,底部会显示下一个活动页面,同时第一页和下一页的动画也会同时开始。 - akaya
1个回答

1
尝试这段代码。
button.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            final View l = findViewById(R.id.main);

            Animation a = AnimationUtils.loadAnimation(
                    YourActivity.this, android.R.anim.fade_out);
            a.setDuration(200);
            a.setAnimationListener(new AnimationListener() {

                public void onAnimationEnd(Animation animation) {
                        // Do what ever you need, if not remove it.  
                }

                public void onAnimationRepeat(Animation animation) {
                        // Do what ever you need, if not remove it.  
                }

                public void onAnimationStart(Animation animation) {
                        // Do what ever you need, if not remove it.  
                }

            });
            l.startAnimation(a);
        }
    });

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接