当前位置: 首页 > wzjs >正文

宁波网站建设费用报价市场推广渠道有哪些

宁波网站建设费用报价,市场推广渠道有哪些,卡姐的wap是什么意思,cms系统中这是一个用于 Android 的自定义 View,模拟蓝牙扫描时的多波浪扩散动画效果。每个波浪的半径逐渐增大,透明度逐渐降低,形成连续的波纹扩散效果。通过调整动画的延迟时间和时长,确保波浪之间的间隙较小,动画流畅且美观。…

这是一个用于 Android 的自定义 View,模拟蓝牙扫描时的多波浪扩散动画效果。每个波浪的半径逐渐增大,透明度逐渐降低,形成连续的波纹扩散效果。通过调整动画的延迟时间和时长,确保波浪之间的间隙较小,动画流畅且美观。

主要特性
多波浪扩散:

支持多个圆圈(波浪)依次扩散,形成连续的波纹效果。

每个圆圈的半径逐渐增大,透明度逐渐降低。

间隙较小:

通过调整动画的延迟时间和动画时长,确保波浪之间的间隙较小。

自定义View:

使用 Canvas 和 Paint 实现自定义绘制。

使用 ValueAnimator 实现平滑的动画效果。

适用场景:
蓝牙扫描界面。

雷达扫描效果。

其他需要波纹扩散动画的场景。

使用方法:
BluetoothScanView 添加到布局文件中。

在 Activity 中调用 startScan() 启动动画,调用 stopScan() 停止动画。

实现步骤
1. 自定义View

import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;import java.util.ArrayList;
import java.util.List;public class BluetoothScanView extends View {private Paint scanPaint; // 画笔private List<Circle> circles; // 存储圆圈的列表private List<ValueAnimator> animators; // 存储动画的列表public BluetoothScanView(Context context) {super(context);init();}public BluetoothScanView(Context context, AttributeSet attrs) {super(context, attrs);init();}public BluetoothScanView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);init();}private void init() {// 初始化画笔scanPaint = new Paint();scanPaint.setColor(Color.BLUE); // 设置颜色scanPaint.setStyle(Paint.Style.STROKE); // 设置样式为描边scanPaint.setStrokeWidth(5); // 设置描边宽度scanPaint.setAntiAlias(true); // 抗锯齿// 初始化圆圈和动画列表circles = new ArrayList<>();animators = new ArrayList<>();}@Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);int centerX = getWidth() / 2; // 中心点X坐标int centerY = getHeight() / 2; // 中心点Y坐标// 绘制所有圆圈for (Circle circle : circles) {scanPaint.setAlpha(circle.alpha); // 设置透明度canvas.drawCircle(centerX, centerY, circle.radius, scanPaint);}}public void startScan() {if (!animators.isEmpty()) {return; // 如果动画已经在运行,直接返回}// 初始化3个圆圈circles.clear();circles.add(new Circle(0, 255)); // 第一个圆圈circles.add(new Circle(0, 255)); // 第二个圆圈circles.add(new Circle(0, 255)); // 第三个圆圈// 为每个圆圈创建独立的动画for (int i = 0; i < circles.size(); i++) {final Circle circle = circles.get(i);ValueAnimator animator = ValueAnimator.ofFloat(0, 1); // 动画范围从0到1animator.setDuration(1500); // 动画时长1.5秒animator.setStartDelay(i * 500); // 每个圆圈延迟0.5秒启动animator.setRepeatCount(ValueAnimator.INFINITE); // 无限循环animator.setRepeatMode(ValueAnimator.RESTART); // 重新开始animator.addUpdateListener(animation -> {float progress = (float) animation.getAnimatedValue(); // 获取当前进度circle.radius = (int) (progress * getWidth() / 2); // 更新半径circle.alpha = (int) (255 * (1 - progress)); // 更新透明度invalidate(); // 触发重绘});animators.add(animator); // 添加到动画列表animator.start(); // 启动动画}}public void stopScan() {// 停止所有动画for (ValueAnimator animator : animators) {animator.cancel();}animators.clear();circles.clear();invalidate(); // 刷新界面}// 圆圈类,用于存储半径和透明度private static class Circle {int radius; // 半径int alpha; // 透明度Circle(int radius, int alpha) {this.radius = radius;this.alpha = alpha;}}
}

2. Activity

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;public class MainActivity extends AppCompatActivity {private BluetoothScanView bluetoothScanView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// 初始化自定义ViewbluetoothScanView = findViewById(R.id.bluetoothScanView);// 确保View尺寸已确定后启动动画bluetoothScanView.post(() -> {bluetoothScanView.startScan(); // 启动扫描动画});}@Overrideprotected void onDestroy() {super.onDestroy();bluetoothScanView.stopScan(); // 停止扫描动画}
}

3. 布局文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:padding="16dp"><!-- 自定义蓝牙扫描View --><com.example.BluetoothScanViewandroid:id="@+id/bluetoothScanView"android:layout_width="300dp"android:layout_height="300dp"android:layout_centerInParent="true" /></RelativeLayout>

运行效果
波浪扩散:

页面加载后,第一个圆圈开始扩散,随后第二个、第三个圆圈依次开始。

每个圆圈的半径逐渐增大,透明度逐渐降低。

间隙较小:

每个波浪之间的启动间隔为 500 毫秒,动画时长为 1500 毫秒,波浪之间的间隙较小。

连续波纹效果:

当一个圆圈的动画结束时,下一个圆圈的动画立即开始,形成连续的波纹效果。

动画循环:

动画无限循环,波纹效果持续不断。

http://www.dtcms.com/wzjs/102379.html

相关文章:

  • 经营网站的备案苏州手机关键词优化
  • 商城类网站用什么做网络项目怎么推广
  • 免费网站在线客服谷歌应用商店app下载
  • 全站仪为什么要建站什么网站可以发布广告
  • 网站竞价托管公司网站推广技巧
  • 自适应网站建设方案小红书关键词检测
  • 上海市卫生健康委员会网站seo优化服务
  • wordpress com搜索引擎优化排名案例
  • 2元域名注册网站搜索引擎优化是什么意思啊
  • 网站案例代码微信seo什么意思
  • 搭建网站需要程序郑州seo优化顾问阿亮
  • 重庆网站建设哪家便宜培训心得体会范文
  • 莆田有哪几家做网站设计的福州关键词排名软件
  • 赤峰网站策划慈溪seo
  • 一个门户网站多少钱营销型网站策划
  • 什么网站可以做宣传2021时事政治热点50条
  • 建设嘉陵摩托车官方网站seo学徒是做什么
  • 怎样才能使网站排名靠前新闻摘抄2022最新5篇
  • 旅行社建网站seo策略工具
  • 重庆市建设委员会网站首页中国企业100强
  • 软装设计师培训学校seo管理与优化期末试题
  • 天津建设信息网站营销方法有哪几种
  • 南昌营销型网站建设sem 优化价格
  • 如何做旅游攻略网站黑马培训机构
  • 中英文双语网站赣州seo外包怎么收费
  • 建设银行网站查开户行北京seo推广外包
  • 做网站需要用到的软件个人网页制作成品欣赏
  • 武汉教育网站建设公司排名连云港百度推广总代理
  • 重庆建设网站的公司简介app代理推广合作50元
  • 徐州市做网站关键词林俊杰mp3