属性动画就是不断改变View的属性啦
3、ObjectAnimator实现动画
之所以选择ObjectAnimator为第一个~~是因为,这个实现最简单~~一行代码,秒秒钟实现动画,下面看个例子:
布局文件:
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@+id/id_container" >
- <ImageView
- android:id="@+id/id_ball"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerInParent="true"
- android:src="@drawable/mv"
- android:scaleType="centerCrop"
- android:onClick="rotateyAnimRun"
- />
- </RelativeLayout>
很简单,就一张妹子图片~
Activity代码:
- package com.example.zhy_property_animation;
- import android.animation.ObjectAnimator;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- public class ObjectAnimActivity extends Activity
- {
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.xml_for_anim);
- }
- public void rotateyAnimRun(View view)
- {
- ObjectAnimator//
- .ofFloat(view, "rotationX", 0.0F, 360.0F)//
- .setDuration(500)//
- .start();
- }
- }
参考:http://blog.csdn.net/lmj623565791/article/details/38067475