您的位置:首页 > 移动开发 > Android开发

王学岗属性动画上(十)——使用xml文件配置多个动画(2)

2015-11-22 22:06 369 查看

一:布局文件,布局文件只有一个
<ImageVIew/>
略去不提

二:看动画xml文件

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

<objectAnimator
android:duration="5000"
android:propertyName="scaleX"
android:valueFrom="0.0"
android:valueTo="1.0"
android:valueType="floatType" />
<objectAnimator
android:duration="5000"
android:propertyName="scaleY"
android:valueFrom="0.0"
android:valueTo="1.0"
android:valueType="floatType" />

</set>


MainActivity

package com.example.seven;

import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
@SuppressLint("NewApi")
public class MainActivity extends Activity {

private ImageView iv_zhangxin;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iv_zhangxin = (ImageView) findViewById(R.id.iv_zhangxin);
MyClick mc = new MyClick();
iv_zhangxin.setOnClickListener(mc);
}

private class MyClick implements OnClickListener {
@Override
public void onClick(View v) {
//AnimatorInflater:动画加载器,功能类似布局加载器
Animator animator= AnimatorInflater.loadAnimator(MainActivity.this,
R.animator.animator_set_x_y);
animator.setDuration(5000);
animator.setTarget(iv_zhangxin);
animator.start();
}

}
}


十和十一大体相差不多,只有动画的xml文件有所改变
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  动画 android