android属性动画实例

郑州app开发android属性动画。布局代码比较简单这里只显示结果图。

成都创新互联-专业网站定制、快速模板网站建设、高性价比浮山网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式浮山网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖浮山地区。费用合理售后完善,十载实体公司更值得信赖。

java代码如下

MainActivity.java

package cn.xhhkj.videoview;

import androidx.appcompat.app.AppCompatActivity;

import androidx.fragment.app.Fragment;

import androidx.fragment.app.FragmentManager;

import android.animation.AnimatorSet;

import android.animation.ObjectAnimator;

import android.app.FragmentTransaction;

import android.graphics.drawable.AnimationDrawable;

import android.media.Mediaplayer;

import android.os.bundle;

import android.util.Log;

import android.view.Menu;

import android.view.View;

import android.view.animation.Animation;

import android.view.animation.AnimationUtils;

import android.view.animation.bounceInterpolator;

import android.view.animation.RotateAnimation;

import android.view.animation.ScaleAnimation;

import android.view.animation.TranslateAnimation;

import android.widget.ArrayAdapter;

import android.widget.AutoCompleteTextView;

import android.widget.Imagebutton;

import android.widget.ImageView;

import android.widget.MediaController;

import android.widget.Toast;

import android.widget.VideoView;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "结果是";

    private ImageView iv_image;

    @Override

    protected void onCreate(bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        iv_image = findViewbyId(R.id.iv_image);

    }

    public void set(View view) {

        AnimatorSet as = new AnimatorSet();

        ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "translationX", 10, 50, 20, 100);

        ObjectAnimator oa2 = ObjectAnimator.ofFloat(iv_image, "scaleY", 0.1f, 2, 1, 2);

        ObjectAnimator oa3 = ObjectAnimator.ofFloat(iv_image, "alpha", 0, 0.5f, 0, 1);

        ObjectAnimator oa4 = ObjectAnimator.ofFloat(iv_image, "rotationY", 0, 180, 90, 360);

        as.setDuration(2000);

        as.setTarget(iv_image);

        as.playTogether(oa, oa2, oa3, oa4);

        as.start();

    }

    public void translate(View view) {

        ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "translationX", 10, 50,20,100,150);

        oa.setDuration(2000);

        oa.start(); //开始动画

    }

    public void scale(View view) {

        ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "scaleY", 0.1f, 2, 1, 2);

oa.setDuration(2000);

oa.start();

    }

    public void rotate(View view) {

        ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "rotation", 0, 180, 90, 360);

        oa.setDuration(2000);

        oa.start();

    }

    public void alpha(View view) {

        ObjectAnimator oa = ObjectAnimator.ofFloat(iv_image, "alpha", 0, 0.5f, 0, 1,0,1);

        oa.setDuration(2000);

        oa.start();

    }

}

网站栏目:android属性动画实例
文章出自:https://www.cdcxhl.com/article0/scdpio.html

成都网站建设公司_创新互联,为您提供App设计服务器托管定制开发网页设计公司静态网站建站公司

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设