动画

旋转掉落与消失动画实现
本文介绍了一种通过Android平台实现视图元素旋转掉落及旋转消失的动画效果的方法。使用了ObjectAnimator和传统AnimationSet来控制ImageView的平移、旋转、缩放和透明度变化,实现了流畅的过渡动画。

//旋转掉落动画

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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:layout_height="match_parent"
    tools:context="com.example.a123.liangqiqi1221yk.DonghuaActivity">
    <ImageView
        android:id="@+id/img"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@mipmap/ic_launcher"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />
</RelativeLayout>
package com.example.a123.liangqiqi1221yk;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

public class DonghuaActivity extends AppCompatActivity {
    private ImageView img;
    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if(msg.what == 1){
                Intent intent = new Intent(DonghuaActivity.this,MainActivity.class);
                startActivity(intent);
                finish();
            }

        }
    };


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_donghua);
        img = (ImageView) findViewById(R.id.img);


        ObjectAnimator animator1 = ObjectAnimator.ofFloat(
                img,
                "translationY",
                0, 400
        );
        ObjectAnimator animator2 = ObjectAnimator.ofFloat(
                img,
                "alpha",
                0, 1
        );
        ObjectAnimator animator3 = ObjectAnimator.ofFloat(
                img,
                "scaleY",
                1, 2
        );
        ObjectAnimator animator4 = ObjectAnimator.ofFloat(
                img,
                "rotationY",
                0, 360
        );

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(3000);
        animatorSet.play(animator1)
                .with(animator2)
                .with(animator3)
                .with(animator4);
        animatorSet.start();


        new Thread(){
            @Override
            public void run() {
                super.run();
                Message msg = new Message();
                msg.what = 1;
                handler.sendMessageDelayed(msg,3000);
            }
        }.start();

    }



}

//旋转消失

package com.example.a123.liangqiqi1221yk;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class DonghuaActivity extends AppCompatActivity {
    private ImageView img;
    private AnimationSet animationSet;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_donghua);
        img = (ImageView) findViewById(R.id.img);
        initAnimates();//初始化动画
        /**
         * 动画的监听事件
         */
        animationSet.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                /**
                 * 结束监听的事件
                 */
                Intent intent = new Intent(DonghuaActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
    }

    //初始化动画
    private void initAnimates() {
        //创建属性动画对象
        animationSet = new AnimationSet(true);
        /** 参数1:从哪个旋转角度开始
         * 参数2:转到什么角度
         * 后4个参数用于设置围绕着旋转的圆的圆心在哪里
         * 参数3:确定x轴坐标的类型,有ABSOLUT绝对坐标、RELATIVE_TO_SELF相对于自身坐标、RELATIVE_TO_PARENT相对于父控件的坐标
         * 参数4:x轴的值,0.5f表明是以自身这个控件的一半长度为x轴
         * 参数5:确定y轴坐标的类型
         * 参数6:y轴的值,0.5f表明是以自身这个控件的一半长度为x轴
         */
        RotateAnimation rotateAnimation = new RotateAnimation(0, 360,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(3000);
//        rotateAnimation.setFillAfter(true);
        animationSet.addAnimation(rotateAnimation);
        /**
         * 移动
         * 参数1~2:x轴的开始位置
         * 参数3~4:y轴的开始位置
         * 参数5~6:x轴的结束位置
         * 参数7~8:x轴的结束位置
         */
        TranslateAnimation translateAnimation =
                new TranslateAnimation(
                        Animation.RELATIVE_TO_SELF, 0f,
                        Animation.RELATIVE_TO_SELF, 0f,
                        Animation.RELATIVE_TO_SELF, 0f,
                        Animation.RELATIVE_TO_SELF, 3f);
        translateAnimation.setDuration(3000);
//        translateAnimation.setFillAfter(true);
        animationSet.addAnimation(translateAnimation);

        //创建一个AnimationSet对象,参数为Boolean型,
        //true表示使用Animation的interpolator,false则是使用自己的
        //创建一个AlphaAnimation对象,参数从完全的透明度,到完全的不透明
        AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
        //设置动画执行的时间
        alphaAnimation.setDuration(3000);
//        alphaAnimation.setFillAfter(true);
        animationSet.addAnimation(alphaAnimation);

        //参数1:x轴的初始值
        //参数2:x轴收缩后的值
        //参数3:y轴的初始值
        //参数4:y轴收缩后的值
        //参数5:确定x轴坐标的类型
        //参数6:x轴的值,0.5f表明是以自身这个控件的一半长度为x轴
        //参数7:确定y轴坐标的类型
        //参数8:y轴的值,0.5f表明是以自身这个控件的一半长度为x轴
        ScaleAnimation scaleAnimation = new ScaleAnimation(
                2, 1f, 2, 1f,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(3000);
//        scaleAnimation.setFillAfter(true);
        animationSet.addAnimation(scaleAnimation);
        //使动画静止
        animationSet.setFillAfter(true);
        img.startAnimation(animationSet);
    }

}

内容概要:本文档介绍了基于3D FDTD(时域有限差分)方法在MATLAB平台上对微带线馈电的矩形天线进行仿真分析的技术方案,重点在于模拟超MATLAB基于3D FDTD的微带线馈矩形天线分析[用于模拟超宽带脉冲通过线馈矩形天线的传播,以计算微带结构的回波损耗参数]宽带脉冲信号通过天线结构的传播过程,并计算微带结构的回波损耗参数(S11),以评估天线的匹配性能和辐射特性。该方法通过建立三维电磁场模型,精确求解麦克斯韦方程组,适用于高频电磁仿真,能够有效分析天线在宽频带内的响应特性。文档还提及该资源属于一个涵盖多个科研方向的综合性MATLAB仿真资源包,涉及通信、信号处理、电力系统、机器学习等多个领域。; 适合人群:具备电磁场与微波技术基础知识,熟悉MATLAB编程及数值仿真的高校研究生、科研人员及通信工程领域技术人员。; 使用场景及目标:① 掌握3D FDTD方法在天线仿真中的具体实现流程;② 分析微带天线的回波损耗特性,优化天线设计参数以提升宽带匹配性能;③ 学习复杂电磁问题的数值建模与仿真技巧,拓展在射频与无线通信领域的研究能力。; 阅读建议:建议读者结合电磁理论基础,仔细理解FDTD算法的离散化过程和边界条件设置,运行并调试提供的MATLAB代码,通过调整天线几何尺寸和材料参数观察回波损耗曲线的变化,从而深入掌握仿真原理与工程应用方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值