android 上下扫描动画,Android扫描雷达动画
很简单的一个组合动画,用好基本动画啥子效果都不怕
老规矩先上图
效果图.gif
ok 来 既然往下翻那就看看如何实现的吧
首先效果分为两部分
第一部分中间指针(其实这里就是一张图片)
第二部分就是波纹,哈哈 也是图片
给中间图片一个旋转动画,一直转的那种
波纹设置放大和渐变的组合动画,然后中间指针执行一次则波纹动画跟着执行一次
这里我把他自定义为一个ScanningView,直接可拿去使用
public class ScanningView extends FrameLayout {
private static final String TAG = "ScanningView";
/**
* 指针
*/
private ImageView ivNeedle;
/**
* 波纹
*/
private ImageView ivRipple;
/**
* 中间文字
*/
private TextView tvTitle;
/**
* 装波纹的容器
*/
private FrameLayout fl_move_circle;
private Context context;
public ScanningView(Context context) {
super(context);
this.context = context;
initView();
}
public ScanningView(Context context, AttributeSet attrs) {
super(context, attrs);
initView();
}
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
ivRipple.setVisibility(VISIBLE);
startOutCircleAnim();
break;
case 2:
addMoveCircle();
break;
}
}
};
/**
* 设置标题
* @param txt
*/
public void setTitle(String txt){
tvTitle.setText(txt);
}
private void initView(){
View v = LayoutInflater.from(getContext()).inflate(R.layout.rotate_view,null);
ivNeedle = v.findViewById(R.id.iv_btn);
ivRipple = v.findViewById(R.id.iv_out_circle);
tvTitle = v.findViewById(R.id.tv_title);
fl_move_circle = v.findViewById(R.id.fl_move_circle);
addView(v, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
startOutCircleAnim();
}
/**
* 发散波纹
*/
private void addMoveCircle() {
final ImageView imageView = new ImageView(getContext());
LayoutParams lp = new LayoutParams(dip2px(getContext(), 100), dip2px(getContext(), 100));
lp.gravity = Gravity.CENTER;
imageView.setLayoutParams(lp);
imageView.setImageResource(R.mipmap.outcircle);
fl_move_circle.addView(imageView);
ObjectAnimator outCircleAnimX = ObjectAnimator.ofFloat(imageView, "scaleX", 1f, 5f);
ObjectAnimator outCircleAnimY = ObjectAnimator.ofFloat(imageView, "scaleY", 1f, 5f);
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(imageView, "alpha", 0.6f, 0);
outCircleAnimX.setDuration(5000);
outCircleAnimY.setDuration(5000);
alphaAnim.setDuration(5000);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(outCircleAnimX, outCircleAnimY, alphaAnim);
animatorSet.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
//移除掉刚才添加的波纹
fl_move_circle.removeView(imageView);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animatorSet.start();
}
/**
* 开始循环的放大缩小波纹
*/
private void startOutCircleAnim() {
ObjectAnimator outCircleAlpha = ObjectAnimator.ofFloat(ivRipple, "alpha", 0.2f, 0.6f);
outCircleAlpha.setDuration(1000);
ObjectAnimator outCircleAnimX = ObjectAnimator.ofFloat(ivRipple, "scaleX", 1f, 1.18f, 1f);
ObjectAnimator outCircleAnimY = ObjectAnimator.ofFloat(ivRipple, "scaleY", 1f, 1.18f, 1f);
outCircleAnimX.setDuration(2000);
outCircleAnimY.setDuration(2000);
outCircleAnimX.setRepeatCount(ValueAnimator.INFINITE);
outCircleAnimY.setRepeatCount(ValueAnimator.INFINITE);
outCircleAnimX.setInterpolator(new LinearInterpolator());
outCircleAnimY.setInterpolator(new LinearInterpolator());
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(outCircleAnimX, outCircleAnimY, outCircleAlpha);
animatorSet.start();
}
/**
* 根据手机的分辨率从 dip 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
/**
* 指针转动
*/
private void pressStart() {
AnimatorSet animatorSet = new AnimatorSet();
ObjectAnimator scaleYIn = ObjectAnimator.ofFloat(ivNeedle, "rotation", 0f, 360f);
scaleYIn.setDuration(1800);
scaleYIn.setInterpolator(new LinearInterpolator());
scaleYIn.setRepeatCount(ValueAnimator.INFINITE);
animatorSet.play(scaleYIn);
animatorSet.start();
}
/**
* 模拟开始
*/
public void onceClick(){
//取消掉循环的波纹
ivRipple.setVisibility(GONE);
pressStart();
new Timer().schedule(new TimerTask() {
@Override
public void run() {
handler.sendEmptyMessage(2);
}
},0,1800);
}
}
布局文件 rotate_view.xml
android:layout_width="match_parent"
android:background="#69C8FA"
android:layout_height="match_parent">
android:id="@+id/fl_move_circle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#69C8FA" />
android:id="@+id/iv_out_circle"
android:layout_width="110dp"
android:layout_height="110dp"
android:layout_gravity="center"
android:background="#69C8FA"
android:alpha="0.6"
android:src="@mipmap/outcircle" />
android:id="@+id/iv_btn"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:src="@mipmap/circle" />
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:textColor="#ffffff"
android:layout_gravity="center"
android:text="扫描中"
android:textSize="@dimen/sp_10"
android:layout_marginTop="@dimen/dp_13"
android:layout_height="wrap_content" />
直接在布局使用即可
android:id="@+id/scanning"
android:layout_width="match_parent"
android:layout_height="match_parent">
java代码中在调用 onceClick()方法可启动动画
scanningView.onceClick();
如果图片也要的话那就拿去吧
中间的指针
circle.png
波纹
outcircle.png
ok 回手掏,鬼刀一开看不见 ,走位,走位
android 上下扫描动画,Android扫描雷达动画相关推荐
- android ar 动画,Android实现支付宝AR扫描动画效果
支付宝AR扫描效果动画实现,具体内容如下 之前一个网友说想要一个支付宝扫描动画的效果demo,所以又花了点时间做了下这个东西,先看效果图 说一下实现的思路,如图中最外围的蓝色的是用两个相距180°的圆 ...
- 雷达扫描定位 android,Android仿微信雷达扫描
废话不多说 先上图(用AS录制的 转换工具不是很好 所以看得效果不是很好) gif5新文件.gif Activity 代码 public class ShapeDrawableActivity ext ...
- android 雷达搜索动画,Android实现微信雷达辐射搜索好友实例(逻辑清晰实现简单)...
Android仿微信雷达扫描,仿安卓微信.云播雷达扫描动画效果点击中间的黑色圆圈开始扫描动画,再次点击复位,需要这种效果的朋友快点收藏了吧. 效果图如下: 这个界面大家肯定都非常熟悉了,下面来说一下原 ...
- 27.Silverlight二维旋转+平面渐变+动画,模拟雷达扫描图之基本框架
在现实生活中的雷达运行扫描到物体的某一些属性(比如:速度,频率)超过安全范围值将会报警.在实际的某一些项目中(比如监控系统),我们也想制作一个雷达扫描图来模拟扫描各种设备那么应该如何做呢? 我们将各种 ...
- Silverlight实用窍门系列:27.Silverlight二维旋转+平面渐变+动画,模拟雷达扫描图之基本框架【附带源码实例】...
在现实生活中的雷达运行扫描到物体的某一些属性(比如:速度,频率)超过安全范围值将会报警.在实际的某一些项目中(比如监控系统),我们也想制作一个雷达扫描图来模拟扫描各种设备那么应该如何做呢? 我们将各种 ...
- android 自定义view之雷达扫描,基于Android自定义控件实现雷达效果
如何制作出类似雷达扫描的效果,具体方法如下 一.效果图 二.实现思路 1.自定义控件RadarView用来画雷达的效果图,可以自定义属性包括 backgroundColor:背景颜色 circleNu ...
- 【Android App】Vulkan实现宇宙中旋转雷达动画效果(附源码和原始视频 超详细必看)
需要源码请点赞关注收藏后评论区留言私信~~~ 一.Vulkan简介 Vulkan是一个跨平台的图形绘制接口,被称为下一代OpenGL,因为尽管OpenGL提供了丰富的图形API,但他在底层实现的C代码 ...
- android+清除循环动画,android自定义View之(4)-一键清除动画
android自定义View之(四)------一键清除动画 1.前言: 自己也是参考别人的一些自定义view例子,学习了一些基本的自定义view的方法.今天,我参考了一些资料,再结合自已的一些理解, ...
- android自定义View之(四)------一键清除动画
1.前言: 自己也是参考别人的一些自定义view例子,学习了一些基本的自定义view的方法.今天,我参考了一些资料,再结合自已的一些理解,做了一个一键清除的动画.当年,我实现这个是用了几张图片,采用F ...
最新文章
- 奇葩错误:cv.imread()读取失败
- selinux php errors,apache php selinux --Syntax error 无法加载模块
- ArrayList迭代修改抛出ConcurrentModificationException
- Android 使用Scroller实现绚丽的ListView左右滑动删除Item效果
- 客座编辑:温孚江,男,现任山东农业大学校长、教授,农业大数据创新战略联盟理事长。...
- python mock_python mock基本使用
- table()函数的使用,提高查询效率
- python线程安全队列用法
- 破解入门(八)-----算法分析与注册机编写
- 微信聊天小程序——(四、聊天页面)
- 搭建Linux虚拟机并编写简单程序
- html中div中文字如何上下居中,div中文字各种垂直居中的方法
- c++win32项目 如何显示后再删除一个绘图_【AutoCAD】AutoCAD绘图软件优化的方法,提高启动速度,防止ACAD意外崩溃...
- HTML网页字体动态显示
- Android8.0 USB系统框架
- 【git与github交互之主分支和次分支切换、合并等】
- 假设检验:p-value,FDR,q-value
- 京东详情页批量关联海报,提高转化80%
- python实现shamir秘密共享算法
- Matlab论文插图绘制模板第70期—带误差棒的柱状图(Bar with Errorbar)
热门文章
- 用线段拟合曲线,纯Java实现缠论笔段
- 使用@Autowired注入RedisTemplate时报java.lang.NullPointerException
- oracle逻辑备份和物理备份,oracle数据库物理备份和逻辑备份区别
- Undefined function or method ' ' for input arguments of type 'double' ---错误解决办法
- 接口测试工具_接口测试工具Jmeter与postman - 瞎扯
- 线段树递归和非递归实现+hdu1166 敌兵布阵
- java 模板引擎_SpringBoot入门系列(四)如何整合Thymeleaf模板引擎
- python3安装setuptools步骤_linux环境下的python安装过程(含setuptools)
- arm Linux 中断管理机制
- 启明云端分享| ESP32-C6有啥特别之处呢?性能如何,搭载的处理器是什么呢?GPIO有多少个呢?采用的框架是什么呢?