2024年安卓最新浅谈Android动画之属性动画ValueAnimator和ObjectAnimator,进入面试送礼送多少钱

学习分享

在当下这个信息共享的时代,很多资源都可以在网络上找到,只取决于你愿不愿意找或是找的方法对不对了

很多朋友不是没有资料,大多都是有几十上百个G,但是杂乱无章,不知道怎么看从哪看起,甚至是看后就忘

如果大家觉得自己在网上找的资料非常杂乱、不成体系的话,我也分享一套给大家,比较系统,我平常自己也会经常研读。

2021最新上万页的大厂面试真题

七大模块学习资料:如NDK模块开发、Android框架体系架构…

只有系统,有方向的学习,才能在段时间内迅速提高自己的技术。

这份体系学习笔记,适应人群:
第一,学习知识比较碎片化,没有合理的学习路线与进阶方向。
第二,开发几年,不知道如何进阶更进一步,比较迷茫。
第三,到了合适的年纪,后续不知道该如何发展,转型管理,还是加强技术研究。如果你有需要,我这里恰好有为什么,不来领取!说不定能改变你现在的状态呢!
由于文章内容比较多,篇幅不允许,部分未展示内容以截图方式展示 。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

android:text=“单一动画”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toBottomOf=“@+id/buttonValue” />

2.设置动画在MainActicity.java中修改

// 创建动画作用对象:此处以Button为例

private Button buttonSpin;

// 动画作用的对象的属性是透明度alpha

// 动画效果是:常规 - 全透明 - 常规

objectAnimator1 = ObjectAnimator.ofFloat(imageView,“alpha”,1F,0F,1F);

buttonSpin.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

AnimatorSet animatorSet = new AnimatorSet();

//执行objectAnimator1

animatorSet.playSequentially(objectAnimator1);

// 设置动画运行的时长

animatorSet.setDuration(5000);

// 启动动画

animatorSet.start();

效果图


在这里插入图片描述

平移


实例说明:


1.设置布局文件在activity_main.xml修改

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout 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=“.MainActivity”>

<Button

android:id=“@+id/buttonSpin”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginStart=“8dp”

android:layout_marginLeft=“8dp”

android:layout_marginTop=“8dp”

android:layout_marginEnd=“8dp”

android:layout_marginRight=“8dp”

android:text=“单一动画”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toBottomOf=“@+id/buttonValue” />

2.设置动画在MainActicity.java中修改

// 创建动画作用对象:此处以Button为例

private Button buttonSpin;

// 动画作用的对象的属性是X轴平移

objectAnimator2 = ObjectAnimator.ofFloat(imageView,“translationX”,0F,300F);

buttonSpin.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

AnimatorSet animatorSet = new AnimatorSet();

//执行objectAnimator2

animatorSet.playSequentially(objectAnimator2);

// 设置动画运行的时长

animatorSet.setDuration(5000);

// 启动动画

animatorSet.start();

效果图


在这里插入图片描述

缩放


实例说明:


1.设置布局文件在activity_main.xml修改

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout 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=“.MainActivity”>

<Button

android:id=“@+id/buttonSpin”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginStart=“8dp”

android:layout_marginLeft=“8dp”

android:layout_marginTop=“8dp”

android:layout_marginEnd=“8dp”

android:layout_marginRight=“8dp”

android:text=“单一动画”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toBottomOf=“@+id/buttonValue” />

2.设置动画在MainActicity.java中修改

// 创建动画作用对象:此处以Button为例

private Button buttonSpin;

// 动画作用的对象的属性是X轴缩放

objectAnimator5 = ObjectAnimator.ofFloat(imageView,“scaleX”,0F,4F,2F);

buttonSpin.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

AnimatorSet animatorSet = new AnimatorSet();

//执行objectAnimator5

animatorSet.playSequentially(objectAnimator5);

// 设置动画运行的时长

animatorSet.setDuration(5000);

// 启动动画

animatorSet.start();

效果图


在这里插入图片描述

在上面的讲解,我们使用了属性动画最基本的四种动画效果:透明度、平移、旋转 & 缩放

即在ObjectAnimator.ofFloat()的第二个参数String property传入alpha、rotation、translationX 和 scaleY 等blabla

| 属性 | 作用 |

| — | — |

| Alpha | 控制View的透明度 |

| TranslationX | 控制X方向的位移 |

| ScaleX | 控制X方向的缩放倍数 |

| TranslationY | 控制Y方向的位移 |

| ScaleY | 控制Y方向的缩放倍数 |

| Rotation | 控制以屏幕方向为轴的旋转度数 |

| RotationX | 控制以X轴为轴的旋转度数 |

| RotationY | 控制以Y轴为轴的旋转度数 |

2、叠加动画


各个属性动画同时进行

实例说明:


1.设置布局文件在activity_main.xml修改

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout 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=“.MainActivity”>

<Button

android:id=“@+id/buttonTogether”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginStart=“8dp”

android:layout_marginLeft=“8dp”

android:layout_marginTop=“8dp”

android:layout_marginEnd=“8dp”

android:layout_marginRight=“8dp”

android:text=“叠加动画”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toBottomOf=“@+id/imageView” />

<ImageView

android:id=“@+id/imageView”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginStart=“8dp”

android:layout_marginLeft=“8dp”

android:layout_marginTop=“8dp”

android:layout_marginEnd=“8dp”

android:layout_marginRight=“8dp”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toTopOf=“parent”

app:srcCompat=“@mipmap/ic_launcher” />

2.设置动画在MainActicity.java中修改

/ imageView = findViewById(R.id.imageView);

buttonTogether = findViewById(R.id.buttonTogether);

buttonSequentially = findViewById(R.id.buttonSequentially);

buttonValue = findViewById(R.id.buttonValue);

buttonSpin = findViewById(R.id.buttonSpin);

// 动画作用的对象的属性是透明度alpha

// 动画效果是:常规 - 全透明 - 常规

objectAnimator1 = ObjectAnimator.ofFloat(imageView,“alpha”,1F,0F,1F);

// 动画作用的对象的属性是X轴平移

objectAnimator2 = ObjectAnimator.ofFloat(imageView,“translationX”,0F,300F);

// 动画作用的对象的属性是y轴平移

objectAnimator3 = ObjectAnimator.ofFloat(imageView,“translationY”,0F,200F);

// 动画作用的对象的属性是旋转

objectAnimator4 = ObjectAnimator.ofFloat(imageView,“rotation”,0F,360F);

// 动画作用的对象的属性是X轴缩放

objectAnimator5 = ObjectAnimator.ofFloat(imageView,“scaleX”,0F,4F,2F);

// 动画作用的对象的属性是y轴缩放

objectAnimator6 = ObjectAnimator.ofFloat(imageView, “scaleY”, 2F,4F);

buttonTogether.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

AnimatorSet animatorSet = new AnimatorSet();

//同时经行objectAnimator2,objectAnimator3,objectAnimator4动画

animatorSet.playTogether(objectAnimator2,objectAnimator3,objectAnimator4);

// 启动动画

animatorSet.start();

}

});

效果图


在这里插入图片描述

3、顺序动画


各个属性动画同时进行

实例说明:


1.设置布局文件在activity_main.xml修改

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout 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=“.MainActivity”>

<Button

android:id=“@+id/buttonSequentially”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginStart=“8dp”

android:layout_marginLeft=“8dp”

android:layout_marginTop=“8dp”

android:layout_marginEnd=“8dp”

android:layout_marginRight=“8dp”

android:text=“顺序动画”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toBottomOf=“@+id/buttonTogether” />

<ImageView

android:id=“@+id/imageView”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_marginStart=“8dp”

android:layout_marginLeft=“8dp”

android:layout_marginTop=“8dp”

android:layout_marginEnd=“8dp”

android:layout_marginRight=“8dp”

app:layout_constraintEnd_toEndOf=“parent”

app:layout_constraintStart_toStartOf=“parent”

app:layout_constraintTop_toTopOf=“parent”

app:srcCompat=“@mipmap/ic_launcher” />

2.设置动画在MainActicity.java中修改

imageView = findViewById(R.id.imageView);

buttonTogether = findViewById(R.id.buttonTogether);

buttonSequentially = findViewById(R.id.buttonSequentially);

buttonValue = findViewById(R.id.buttonValue);

buttonSpin = findViewById(R.id.buttonSpin);

// 动画作用的对象的属性是透明度alpha

// 动画效果是:常规 - 全透明 - 常规

objectAnimator1 = ObjectAnimator.ofFloat(imageView,“alpha”,1F,0F,1F);

// 动画作用的对象的属性是X轴平移

objectAnimator2 = ObjectAnimator.ofFloat(imageView,“translationX”,0F,300F);

// 动画作用的对象的属性是y轴平移

objectAnimator3 = ObjectAnimator.ofFloat(imageView,“translationY”,0F,200F);

// 动画作用的对象的属性是旋转

objectAnimator4 = ObjectAnimator.ofFloat(imageView,“rotation”,0F,360F);

面试复习路线,梳理知识,提升储备

自己的知识准备得怎么样,这直接决定了你能否顺利通过一面和二面,所以在面试前来一个知识梳理,看需不需要提升自己的知识储备是很有必要的。

关于知识梳理,这里再分享一下我面试这段时间的复习路线:(以下体系的复习资料是我从各路大佬收集整理好的)

  • 架构师筑基必备技能
  • Android高级UI与FrameWork源码
  • 360°全方面性能调优
  • 解读开源框架设计思想
  • NDK模块开发
  • 微信小程序
  • Hybrid 开发与Flutter

知识梳理完之后,就需要进行查漏补缺,所以针对这些知识点,我手头上也准备了不少的电子书和笔记,这些笔记将各个知识点进行了完美的总结:

Android开发七大模块核心知识笔记

《960全网最全Android开发笔记》

《379页Android开发面试宝典》

历时半年,我们整理了这份市面上最全面的安卓面试题解析大全
包含了腾讯、百度、小米、阿里、乐视、美团、58、猎豹、360、新浪、搜狐等一线互联网公司面试被问到的题目。熟悉本文中列出的知识点会大大增加通过前两轮技术面试的几率。

如何使用它?

1.可以通过目录索引直接翻看需要的知识点,查漏补缺。
2.五角星数表示面试问到的频率,代表重要推荐指数

《507页Android开发相关源码解析》

只要是程序员,不管是Java还是Android,如果不去阅读源码,只看API文档,那就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。

真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

960全网最全Android开发笔记》**

[外链图片转存中…(img-M7h0HGvc-1715828332977)]

《379页Android开发面试宝典》

历时半年,我们整理了这份市面上最全面的安卓面试题解析大全
包含了腾讯、百度、小米、阿里、乐视、美团、58、猎豹、360、新浪、搜狐等一线互联网公司面试被问到的题目。熟悉本文中列出的知识点会大大增加通过前两轮技术面试的几率。

如何使用它?

1.可以通过目录索引直接翻看需要的知识点,查漏补缺。
2.五角星数表示面试问到的频率,代表重要推荐指数

[外链图片转存中…(img-dWt31Dld-1715828332978)]

《507页Android开发相关源码解析》

只要是程序员,不管是Java还是Android,如果不去阅读源码,只看API文档,那就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。

真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值