2024年最新MPAndroidChart 教程:动画 Animations(十),2024年最新Android高级工程师面试实战

最后

这里附上上述的技术体系图相关的几十套腾讯、头条、阿里、美团等公司2021年的面试题,把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,这里以图片的形式给大家展示一部分。

相信它会给大家带来很多收获:

img

当程序员容易,当一个优秀的程序员是需要不断学习的,从初级程序员到高级程序员,从初级架构师到资深架构师,或者走向管理,从技术经理到技术总监,每个阶段都需要掌握不同的能力。早早确定自己的职业方向,才能在工作和能力提升中甩开同龄人。

  • 无论你现在水平怎么样一定要 持续学习 没有鸡汤,别人看起来的毫不费力,其实费了很大力,这四个字就是我的建议!!!
  • 我希望每一个努力生活的IT工程师,都会得到自己想要的,因为我们很辛苦,我们应得的。

当我们在抱怨环境,抱怨怀才不遇的时候,没有别的原因,一定是你做的还不够好!

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

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

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

// 设置动画

chart.animateX(8000); // 图1

chart.animateY(8000); // 图2

chart.animateXY(8000,8000); // 图3

chart.animateY(8000, Easing.EasingOption.EaseOutBounce); // 图4

二、概述


MPAndroidChart 的动画机制只在Android API 11 (Android 3.0.x) 和以上有效。

在低于 Android 3.0.x 的版本中动画不会执行(但不会引起 crash)。

所有图表类型都支持动画,可以用来创建/建立图表在一个很棒的方法。三种不同的动画方法存在,动画,或者x轴和y轴分别:

  • animateX(int durationMillis) : 水平轴的图表值动画,这意味着在指定的时间内从左到右 建立图表

  • animateY(int durationMillis) : 垂直轴的图表值动画,这意味着在指定的时间内从下到上 建立图表

  • animateXY(int xDuration, int yDuration) : 两个轴的图表值动画,从左到右,从下到上 建立图表

mChart.animateX(3000); // animate horizontal 3000 milliseconds

// or:

mChart.animateY(3000); // animate vertical 3000 milliseconds

// or:

mChart.animateXY(3000, 3000); // animate horizontal and vertical 3000 milliseconds

任意一种 animate(...) 动画方法被调用后,无需再调用 invalidate() 方法。

三、ChartAnimator 动画源码分析


/**

  • Object responsible for all animations in the Chart. ANIMATIONS ONLY WORK FOR

  • API LEVEL 11 (Android 3.0.x) AND HIGHER.

*/

@SuppressLint(“NewApi”)

public class ChartAnimator {

/** object that is updated upon animation update */

private AnimatorUpdateListener mListener;

public ChartAnimator() {}

public ChartAnimator(AnimatorUpdateListener listener) {

mListener = listener;

}

/** the phase that is animated and influences the drawn values on the y-axis */

protected float mPhaseY = 1f;

/** the phase that is animated and influences the drawn values on the x-axis */

protected float mPhaseX = 1f;

// 下面的动画方法

}

1) animateX( … ) 方法的源码

/**

  • Animates the rendering of the chart on the x-axis with the specified

  • animation time. If animate(…) is called, no further calling of

  • invalidate() is necessary to refresh the chart.

  • @param durationMillis

*/

public void animateX(int durationMillis) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, “phaseX”, 0f, 1f);

animatorX.setDuration(durationMillis);

animatorX.addUpdateListener(mListener);

animatorX.start();

}

public void animateX(int durationMillis, Easing.EasingOption easing) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, “phaseX”, 0f, 1f);

animatorX.setInterpolator(Easing.getEasingFunctionFromOption(easing));

animatorX.setDuration(durationMillis);

animatorX.addUpdateListener(mListener);

animatorX.start();

}

public void animateX(int durationMillis, EasingFunction easing) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, “phaseX”, 0f, 1f);

animatorX.setInterpolator(easing);

animatorX.setDuration(durationMillis);

animatorX.addUpdateListener(mListener);

animatorX.start();

}

2) animateY( … ) 方法的源码

/**

  • Animates the rendering of the chart on the y-axis with the specified

  • animation time. If animate(…) is called, no further calling of

  • invalidate() is necessary to refresh the chart.

  • @param durationMillis

*/

public void animateY(int durationMillis) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, “phaseY”, 0f, 1f);

animatorY.setDuration(durationMillis);

animatorY.addUpdateListener(mListener);

animatorY.start();

}

public void animateY(int durationMillis, Easing.EasingOption easing) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, “phaseY”, 0f, 1f);

animatorY.setInterpolator(Easing.getEasingFunctionFromOption(easing));

animatorY.setDuration(durationMillis);

animatorY.addUpdateListener(mListener);

animatorY.start();

}

public void animateY(int durationMillis, EasingFunction easing) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, “phaseY”, 0f, 1f);

animatorY.setInterpolator(easing);

animatorY.setDuration(durationMillis);

animatorY.addUpdateListener(mListener);

animatorY.start();

}

3) animateXY( … ) 方法的源码

/**

  • Animates the drawing / rendering of the chart on both x- and y-axis with

  • the specified animation time. If animate(…) is called, no further

  • calling of invalidate() is necessary to refresh the chart.

  • @param durationMillisX

  • @param durationMillisY

*/

public void animateXY(int durationMillisX, int durationMillisY) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, “phaseY”, 0f, 1f);

animatorY.setDuration(

durationMillisY);

ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, “phaseX”, 0f, 1f);

animatorX.setDuration(

durationMillisX);

// make sure only one animator produces update-callbacks (which then

// call invalidate())

if (durationMillisX > durationMillisY) {

animatorX.addUpdateListener(mListener);

} else {

animatorY.addUpdateListener(mListener);

}

animatorX.start();

animatorY.start();

}

public void animateXY(int durationMillisX, int durationMillisY, Easing.EasingOption easingX,

Easing.EasingOption easingY) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, “phaseY”, 0f, 1f);

animatorY.setInterpolator(Easing.getEasingFunctionFromOption(easingY));

animatorY.setDuration(

durationMillisY);

ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, “phaseX”, 0f, 1f);

animatorX.setInterpolator(Easing.getEasingFunctionFromOption(easingX));

animatorX.setDuration(

durationMillisX);

// make sure only one animator produces update-callbacks (which then

// call invalidate())

if (durationMillisX > durationMillisY) {

animatorX.addUpdateListener(mListener);

} else {

animatorY.addUpdateListener(mListener);

}

animatorX.start();

animatorY.start();

}

public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easingX,

EasingFunction easingY) {

if (android.os.Build.VERSION.SDK_INT < 11)

return;

ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, “phaseY”, 0f, 1f);

animatorY.setInterpolator(easingY);

animatorY.setDuration(

durationMillisY);

ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, “phaseX”, 0f, 1f);

animatorX.setInterpolator(easingX);

animatorX.setDuration(

durationMillisX);

// make sure only one animator produces update-callbacks (which then

// call invalidate())

if (durationMillisX > durationMillisY) {

animatorX.addUpdateListener(mListener);

} else {

animatorY.addUpdateListener(mListener);

}

animatorX.start();

animatorY.start();

}

四、缓动动画 (Animation easing)


这个库可以让你对动画应用”缓动函数”。

您可以选择以下预定义的静态 Easing.EasingOption :

public enum EasingOption {

Linear,

EaseInQuad,

EaseOutQuad,

EaseInOutQuad,

EaseInCubic,

EaseOutCubic,

EaseInOutCubic,

EaseInQuart,

EaseOutQuart,

学习福利

【Android 详细知识点思维脑图(技能树)】

其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。

虽然 Android 没有前几年火热了,已经过去了会四大组件就能找到高薪职位的时代了。这只能说明 Android 中级以下的岗位饱和了,现在高级工程师还是比较缺少的,很多高级职位给的薪资真的特别高(钱多也不一定能找到合适的),所以努力让自己成为高级工程师才是最重要的。

这里附上上述的面试题相关的几十套字节跳动,京东,小米,腾讯、头条、阿里、美团等公司19年的面试题。把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。

由于篇幅有限,这里以图片的形式给大家展示一小部分。

网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。

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

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

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

现在高级工程师还是比较缺少的**,很多高级职位给的薪资真的特别高(钱多也不一定能找到合适的),所以努力让自己成为高级工程师才是最重要的。

这里附上上述的面试题相关的几十套字节跳动,京东,小米,腾讯、头条、阿里、美团等公司19年的面试题。把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。

由于篇幅有限,这里以图片的形式给大家展示一小部分。

[外链图片转存中…(img-m6HSAFxc-1715143205925)]

网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。

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

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值