动画

package com.example.yan.lianxi555;

import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class AnimatomainActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView image;
    private Button but1;
    private Button but2;
    private Button but3;
    private Button but4;
    private LinearLayout liner;
    private Button but5;
    private Button but6;
    private LinearLayout liner2;
    private Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.animatoractivity_main);
        initView();

         context = AnimatomainActivity.this;
    }

    private void initView() {
        image = (ImageView) findViewById(R.id.image);
        but1 = (Button) findViewById(R.id.but1);
        but2 = (Button) findViewById(R.id.but2);
        but3 = (Button) findViewById(R.id.but3);
        but4 = (Button) findViewById(R.id.but4);
        liner = (LinearLayout) findViewById(R.id.liner);
        but5 = (Button) findViewById(R.id.but5);
        but6 = (Button) findViewById(R.id.but6);
        liner2 = (LinearLayout) findViewById(R.id.liner2);

        but1.setOnClickListener(this);
        but2.setOnClickListener(this);
        but3.setOnClickListener(this);
        but4.setOnClickListener(this);
        but5.setOnClickListener(this);
        but6.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.but1:

             Animator animator = AnimatorInflater.loadAnimator(context,R.animator.pingyi);
             animator.setTarget(image);
             animator.start();

                break;
            case R.id.but2:
                Animator animator1 = AnimatorInflater.loadAnimator(context,R.animator.scale);
                animator1.setTarget(image);
                animator1.start();
                break;
            case R.id.but3:
                Animator animator2 = AnimatorInflater.loadAnimator(context,R.animator.rotate);
                animator2.setTarget(image);
                animator2.start();
                break;
            case R.id.but4:
                Animator animator3 = AnimatorInflater.loadAnimator(context,R.animator.alpha);
                animator3.setTarget(image);
                animator3.start();
                break;
            case R.id.but5:
                Animator animator4 = AnimatorInflater.loadAnimator(context,R.animator.set);
                animator4.setTarget(image);
                animator4.start();
                break;
            case R.id.but6:
                startActivity(new Intent(this,LoginActivity.class));
                break;
        }
    }
}

shape



    
    
    




渐变



    


    

其他的和渐变一样valueTo="100"

你可能感兴趣的:(动画)