安卓_动画

来源:互联网 发布:重庆网络有限 编辑:程序博客网 时间:2024/05/16 09:49




****布局
    <ImageView
        android:id="@+id/IV"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/b" />


****MainActivity
  IV = (ImageView) findViewById(R.id.IV);
        //旋转


        RotateAnimation animRotate = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f
                , Animation.RELATIVE_TO_SELF, 0.5f);




        animRotate.setDuration(1000);//时间
        animRotate.setFillAfter(true);//保持状态




        //缩放




        ScaleAnimation animation1 = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f
                , Animation.RELATIVE_TO_SELF, 0.5f);




        animation1.setDuration(1000);
        animation1.setFillAfter(true);


        //渐变
        AlphaAnimation animation2 = new AlphaAnimation(0, 1);
        animation2.setDuration(2000);
        animation2.setFillAfter(true);


        //动画集合


        AnimationSet set = new AnimationSet(false);
        set.addAnimation(animation1);
        set.addAnimation(animation2);
        set.addAnimation(animRotate);




        IV.startAnimation(set);

原创粉丝点击