zoukankan      html  css  js  c++  java
  • Android 动画之ScaleAnimation应用详解

    本节讲解ScaleAnimation 动画,
    ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
    参数说明: 


    float fromX 动画起始时 X坐标上的伸缩尺寸
    float toX 动画结束时 X坐标上的伸缩尺寸
    float fromY 动画起始时Y坐标上的伸缩尺寸
    float toY 动画结束时Y坐标上的伸缩尺寸
    int pivotXType 动画在X轴相对于物件位置类型
    float pivotXValue 动画相对于物件的X坐标的开始位置
    int pivotYType 动画在Y轴相对于物件位置类型
    float pivotYValue 动画相对于物件的Y坐标的开始位置

    栗子:

     
    public class MainActivity extends Activity { 
    ImageView image; 
    Button start; 
    Button cancel; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    image = (ImageView) findViewById(R.id.main_img); 
    start = (Button) findViewById(R.id.main_start); 
    cancel = (Button) findViewById(R.id.main_cancel); 
    /** 设置缩放动画 */ 
    final ScaleAnimation animation =new ScaleAnimation(0.0f, 1.4f, 0.0f, 1.4f, 
    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); 
    animation.setDuration(2000);//设置动画持续时间 
    /** 常用方法 */ 
    //animation.setRepeatCount(int repeatCount);//设置重复次数 
    //animation.setFillAfter(boolean);//动画执行完后是否停留在执行完的状态 
    //animation.setStartOffset(long startOffset);//执行前的等待时间 
    start.setOnClickListener(new OnClickListener() { 
    public void onClick(View arg0) { 
    image.setAnimation(animation); 
    /** 开始动画 */ 
    animation.startNow(); 
    } 
    }); 
    cancel.setOnClickListener(new OnClickListener() { 
    public void onClick(View v) { 
    /** 结束动画 */ 
    animation.cancel(); 
    } 
    }); 
    } 
    } 
  • 相关阅读:
    streamreader
    python编码问题总结
    linux rz上传文件及出错解决方案
    使用linux远程登录另一台linux
    利用Django实现RESTful API(一)
    windows下搭建vue开发环境
    windows下python虚拟环境virtualenv安装和使用
    SonarQube的安装、配置与使用
    windows下安装Mysql(图文详解)
    静态代码分析工具sonarqube+sonar-runner的安装配置及使用
  • 原文地址:https://www.cnblogs.com/AceIsSunshineRain/p/5188974.html
Copyright © 2011-2022 走看看