android自定义钟摆loadingView
来源:互联网 发布:电脑定闹钟软件 编辑:程序博客网 时间:2024/04/28 02:23
最近在看github的时候看见了好多好有趣的效果,便想要参考上面的项目,自己自主的实现出来,比如下面这个:
android自定义钟摆loadingView:
可以看到这个实现了自定义钟摆的效果,接下来进行实现的分析。
我们可以从中看到其实就只有三部分内容:
第一部分就是左边第一个小圆球的摇摆。
第二部分就是中间三个小球的震动。
第三部分就是最后一个小球的摇摆。
由于第一部分跟第三部分相当于镜像的感觉,所以实现第一个就相当于实现了第三个,所以只说明第一部分的代码,代码如下;
//旋转动画 leftRotate = new RotateAnimation(0, DEGREE, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, -2f); //重复的次数 leftRotate.setRepeatCount(1); //设置旋转的模式,当前为反转模式 leftRotate.setRepeatMode(Animation.REVERSE); leftRotate.setDuration(DURATION); //插值器 leftRotate.setInterpolator(new LinearInterpolator()); //监听事件 leftRotate.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { startLefeShake(); startRightRotate(); } @Override public void onAnimationRepeat(Animation animation) { } });
主要使用了旋转动画进行实现,了解动画一下子就能看出这是啥了,就不过多叙述了。
我们主要工作是在动画结束的时候开启中间小球的震动以及第三部分的摇摆:
startLefeShake(); startRightRotate();
private void startLefeShake(){ two.startAnimation(leftShake); three.startAnimation(leftShake); four.startAnimation(leftShake); } private void startRightShake(){ two.startAnimation(rightShake); three.startAnimation(rightShake); four.startAnimation(rightShake); }
接下来看中间部分,我们使用平移动画进行小球的震动操作:
leftShake=new TranslateAnimation(0, 2, 0, 0); leftShake.setDuration(DURATION); leftShake.setInterpolator(new CycleInterpolator(2)); rightShake=new TranslateAnimation(0, -2, 0, 0); rightShake.setDuration(DURATION); rightShake.setInterpolator(new CycleInterpolator(2));
主要使用了CycleInterpolator这个插值器。
其实熟悉动画的朋友一看就能做出来,但是还是要多练,才能熟悉使用各种api,所以就有了这个项目。
想看全部的朋友可以去的github中下载:
https://github.com/JerryChan123/android-learning
1 0
- android自定义钟摆loadingView
- Android 自定义通用的loadingview
- Android自定义控件之钟摆菜单
- Android 自定义View(四)IOS LoadingView
- Android自定义View: 如何实现类钟摆的动画效果?
- iOS自定义LoadingView
- 自定义LoadingView大全
- 自定义LoadingView大全
- 安卓自定义环形LoadingView
- Android 自定义View-图片文字变色,实现酷炫LoadingView或者进度条
- (Android自定义View)来来来,一起再撸一个Material风格loadingView。
- Android网络加载通用LoadingView
- Android学习笔记--LoadingView封装
- android仿ios菊花LoadingView
- 自定义View实现钟摆效果进度条PendulumView
- andorid自定义LoadingView效果(小吃货)
- 自定义LoadingView大全之转动立方体
- 自定view实践(一) 自定义loadingView
- linux防火墙的设置
- Android 动画详解
- NSTimer用法,暂停,继续,初始化
- 群发图文素材(测试号操作及出现的问题)
- Core Data入门使用
- android自定义钟摆loadingView
- Trie树:应用于统计和排序
- Linux下面批量删除某种类型的文件
- 【每日算法】快速幂
- iOS从plist文件里面读取内容
- ADB常用命令
- 线程池封装类—借鉴ImageLoader的线程工厂
- 2016大视频市场预测
- andorid自定义LoadingView效果(小吃货)