Android缩放动画[ScaleAnimation]

 1 @Override  2     protected void onCreate(Bundle savedInstanceState) {  3         super.onCreate(savedInstanceState);  4  setContentView(R.layout.activity_main);  5         
 6         logo = (ImageView)findViewById(R.id.imageView1);  7         //实例化logo控件
 8         
 9         btndl = (Button)findViewById(R.id.button1); 10         btnzc = (Button)findViewById(R.id.Button01); 11         //实例化按钮控件
12         
13  btndl.setVisibility(View.INVISIBLE); 14  btnzc.setVisibility(View.INVISIBLE); 15         //设置按钮不显示
16         
17         ScaleAnimation animation = new ScaleAnimation(0, 1, 0, 1,Animation.RELATIVE_TO_SELF, 0.5f,1, 0.5f); 18 
19         /**
20  * 21  * @param fromX 起始x轴位置,0为最小,1为原始,float形 22  * @param toX 同上 23  * @param fromY 同上T 24  * @param toY 同上 25  * @param pivotXType 用来约束pivotXValue的取值。取值有三种:Animation.ABSOLUTE,Animation.RELATIVE_TO_SELF,Animation.RELATIVE_TO_PARENT 26  * Type:Animation.ABSOLUTE:绝对,若是设置这种类型,后面pivotXValue取值就必须是像素点;好比:控件X方向上的中心点,pivotXValue的取值mIvScale.getWidth() / 2f 27  * Animation.RELATIVE_TO_SELF:相对于控件本身,设置这种类型,后面pivotXValue取值就会去拿这个取值是乘上控件自己的宽度;好比:控件X方向上的中心点,pivotXValue的取值0.5f 28  * Animation.RELATIVE_TO_PARENT:相对于它父容器(这个父容器是指包括这个这个作动画控件的外一层控件), 原理同上, 29  * @param pivotXValue 配合pivotXType使用,原理在上面 30  * @param pivotYType 同from/to 31  * @param pivotYValue 原理同上 32          */
33         
34         animation.setDuration(2000); 35         //设置持续时间
36         animation.setFillAfter(true); 37         //设置动画结束以后的状态是不是动画的最终状态,true,表示是保持动画结束时的最终状态
38         animation.setRepeatCount(0); 39         //设置循环次数,0为1次
40  logo.startAnimation(animation); 41         //开始动画
42         
43         myTimer = new Timer(); 44         
45         /**
46  * 47  * 创建计时器 48  * 当logo动画结束后 49  * 显示按钮 50  * 51          */
52         
53         myTimer.schedule(new TimerTask() { 54             
55  @Override 56             public void run() { 57                 // TODO Auto-generated method stub
58                 runOnUiThread(new Runnable() { 59                     public void run() { 60  btndl.setVisibility(View.VISIBLE); 61  btnzc.setVisibility(View.VISIBLE); 62  } 63  }); 64  } 65         }, 2000); 66         
67     }
相关文章
相关标签/搜索