动画

来源:互联网 发布:fc2域名用不了2017 编辑:程序博客网 时间:2022/05/27 14:43
int x=300;            //translationY平移Y轴        //translationX平移X轴        //rotation上下旋转        TranslateAnimation t = new TranslateAnimation(0, 200, 0, 0);//设置动画的偏移位移        TranslateAnimation ta = new TranslateAnimation(0, 0, 0, x);//设置动画的偏移位移        AlphaAnimation alp = new AlphaAnimation(1.0f, 0.0f);        final RotateAnimation rot = new RotateAnimation(0, -360, Animation.RELATIVE_TO_SELF, 0.5f,Animation.RELATIVE_TO_SELF, 0.5f);        ScaleAnimation sca= new ScaleAnimation(1.0f, 2.0f, 1.0f, 2.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);        AnimationSet set=new AnimationSet(true);       /* set.addAnimation(t);*/                   //设置动画结束之后保持结束的状态scaleAnimation.setFillAfter(true);       // set.addAnimation(rot);        set.addAnimation(ta);        set.addAnimation(alp);        set.addAnimation(sca);        set.setDuration(3000);        img.startAnimation(set);        set.setAnimationListener(new Animation.AnimationListener() {            @Override            public void onAnimationStart(Animation animation) {            }            @Override            public void onAnimationEnd(Animation animation) {            //结束监听                rot.setDuration(1000);                rot.setFillAfter(true);               img.setAnimation(rot);                rot.setAnimationListener(new Animation.AnimationListener() {                    @Override                    public void onAnimationStart(Animation animation) {                    }                    @Override                    public void onAnimationEnd(Animation animation) {                        FragmentGouwu fr=new FragmentGouwu();                        MainActivity ma= (MainActivity) getActivity();                        FragmentDonghua don=new FragmentDonghua();                        ma.getSupportFragmentManager().beginTransaction().replace(R.id.frag,fr).show(fr).commit();                    }                    @Override                    public void onAnimationRepeat(Animation animation) {                    }                });            }            @Override            public void onAnimationRepeat(Animation animation) {            }        });
原创粉丝点击