通过overridePendingTransition(R.anim.zoomin, R.anim.zoomout);方法我实现了页面切换的淡入淡出动画效果
现在想在程序中动态设置动画的持续时间,不知道具体怎样实现,还请各位高手帮忙!

解决方案 »

  1.   


    1.Animation animation;  [email protected]
    2.  [email protected]
    3.animation=AnimationUtils.loadAnimation(this, R.anim.animation);  [email protected]
    4.  [email protected]
    5.然后再想要实现动画效果的控件上通过使用 startAnimation() 方法进行添加。  [email protected]
    6.  [email protected]
    7.// 编写动画对象,并且获取自定应的动画样式  [email protected]
    8.  [email protected]
    9.animation=AnimationUtils.loadAnimation(this, R.anim.animation);  [email protected]
    10.  [email protected]
    11.        spinner.setOnTouchListener(new Spinner.OnTouchListener() {  [email protected]
    12.  [email protected]
    13.                      [email protected]
    14.  [email protected]
    15.                     @Override  [email protected]
    16.  [email protected]
    17.                     public boolean onTouch(View v, MotionEvent event) {  [email protected]
    18.  [email protected]
    19.                            // TODO Auto-generated method stub  [email protected]
    20.  [email protected]
    21.                            // 运行动画 animation  [email protected]
    22.  [email protected]
    23.                            v.startAnimation(animation);  [email protected]
    24.  [email protected]
    25.                            // 将 spinner 的可见性设置为不可见状态  [email protected]
    26.  [email protected]
    27.                            v.setVisibility(View.INVISIBLE);  [email protected]
    28.  [email protected]
    29.                            return false;  [email protected]
    30.  [email protected]
    31.                     }  [email protected]
    32.  [email protected]
    33.              });  [email protected]
    .
      

  2.   

    参考Animation类的setDuration()可以设置持续时间