我们的android补帧动画的制作(详解)

第一我们要了解的是我们android中的动画包括我们的透明(alphaAnimation)动画
缩放动画ScaleAnimation 旋转动画rotateAnimation 和我们的平移动画

开始先通过图片普及一些基础的知识

在这里插入图片描述
在这里插入图片描述

制作我们的android中动画的第一步:编写我们的动画布局文件 step ----one -----

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
旋转动画:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
平移动画:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
然后开始我们的项目实战:
在这里插入图片描述
第一个透明动画对应的xml文件:
在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 在我们的这个位置的会啊就是设置我们的透明度渐变动画-->
    <alpha
        android:fromAlpha="0"
        android:toAlpha="1"
        android:duration="2000"
        android:repeatMode = "reverse"
        android:repeatCount = "infinite"
        />
</set>

第二个旋转动画对应的xml文件:
在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--todo   这个位置的话就是设置我们的就是旋转的动画-->
    <rotate
        android:fromDegrees="0"
        android:toDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration = "3000"
        android:repeatMode= "reverse"
        android:repeatCount = "infinite"
        />
<!--    pivotX 指的是我们的中心轴的位置-->
</set>

然后的话就是我们的缩放的动画:
在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--然后的话就是我们的这个位置的话设置我们的缩放动画-->
    <scale
        android:fromXScale="1"
        android:fromYScale="1"
        android:toXScale="2"
        android:toYScale="2"
        android:pivotY="50%"
        android:pivotX="50%"
        android:duration ="3000"
        android:repeatMode = "reverse"
        android:repeatCount = "infinite"
        />
</set>

平移的动画效果:
在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<!--然后的话就是我们的平移动画-->
    <translate
         android:fromXDelta="0"
         android:fromYDelta="0"
         android:toXDelta="300"
         android:toYDelta="300"
         android:duration = "5000"
         android:repeatCount= "infinite"
         android:repeatMode = "reverse"
        />
</set>

在这里插入图片描述
代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:id="@+id/LinerrLayout"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
<ImageView
    android:src="@drawable/home3"
    android:id="@+id/imageview"
    android:layout_width="match_parent"
    android:layout_height="30dp"/>
    <ImageView
        android:src="@drawable/home3"
        android:id="@+id/imageview1"
        android:layout_width="match_parent"
        android:layout_height="30dp"/>
    <ImageView
        android:src="@drawable/home3"
        android:id="@+id/imageview2"
        android:layout_width="match_parent"
        android:layout_height="30dp"/>
    <ImageView
        android:src="@drawable/home3"
        android:id="@+id/imageview3"
        android:layout_width="match_parent"
        android:layout_height="30dp"/>
</LinearLayout>

然后的话就是我们的java部分的代码:
在这里插入图片描述
代码:

package com.example.animation_bujian;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class MainActivity extends AppCompatActivity {
    private LinearLayout LinerrLayout;
    private ImageView imageview;
    private ImageView imageview1;

    private ImageView imageview2;
    private ImageView imageview3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//         在我们的这个位置的话实现我们的就是补间动画的效果
        LinerrLayout = (LinearLayout) findViewById(R.id.LinerrLayout);
        imageview = (ImageView) findViewById(R.id.imageview);

        imageview1 = (ImageView) findViewById(R.id.imageview1);


        imageview2 = (ImageView) findViewById(R.id.imageview2);
        imageview3 = (ImageView) findViewById(R.id.imageview3);

// 在我们的这个位置的话就是调用我们的补间动画
        imageview.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // 在我们的这个位置的话就是设置我们的点击事件
                // 在我们的这个位置的话就是已经创建了我们的动画对象
                Animation anim = AnimationUtils.loadAnimation(MainActivity.this,R.anim.alpha);
                //然后的话就是在我们的这个位置的话就是设置我们的动画:
                imageview.startAnimation(anim);
                // 然后的话就是设置我们的旋转动画
                Animation animation_rotate = AnimationUtils.loadAnimation(MainActivity.this,R.anim.rotate);
                imageview1.startAnimation(animation_rotate);

                Animation animation_scale = AnimationUtils.loadAnimation(MainActivity.this,R.anim.scale);
                imageview2.startAnimation(animation_scale);

                Animation animation_tranitate = AnimationUtils.loadAnimation(MainActivity.this,R.anim.tranatate);
                imageview3.startAnimation(animation_tranitate);
            }
        });
    }
}

然后的话就是我们的结果图:
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值