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

环保网站源码公司logo图案大全

环保网站源码,公司logo图案大全,制作手机软件的软件,企业网组建这是一个用于 Android 的自定义 View,模拟蓝牙扫描时的多波浪扩散动画效果。每个波浪的半径逐渐增大,透明度逐渐降低,形成连续的波纹扩散效果。通过调整动画的延迟时间和时长,确保波浪之间的间隙较小,动画流畅且美观。…

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

主要特性:
多波浪扩散:

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

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

间隙较小:

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

自定义View:

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

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

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

雷达扫描效果。

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

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

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

实现步骤
1. 自定义View
BluetoothScanView.kt

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.Viewclass BluetoothScanView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {private val scanPaint = Paint().apply {color = Color.BLUEstyle = Paint.Style.STROKEstrokeWidth = 5fisAntiAlias = true}private val circles = mutableListOf<Circle>()private val animators = mutableListOf<ValueAnimator>()private fun init() {// 初始化圆圈和动画列表circles.clear()animators.clear()}override fun onDraw(canvas: Canvas) {super.onDraw(canvas)val centerX = width / 2val centerY = height / 2// 绘制所有圆圈for (circle in circles) {scanPaint.alpha = circle.alphacanvas.drawCircle(centerX.toFloat(), centerY.toFloat(), circle.radius.toFloat(), scanPaint)}}fun startScan() {if (animators.isNotEmpty()) returninit()// 初始化3个圆圈repeat(3) { circles.add(Circle(0, 255))}// 为每个圆圈创建独立的动画for ((i, circle) in circles.withIndex()) {val animator = ValueAnimator.ofFloat(0f, 1f).apply {duration = 1500startDelay = i * 500LrepeatCount = ValueAnimator.INFINITErepeatMode = ValueAnimator.RESTARTaddUpdateListener {val progress = animatedValue as Floatcircle.radius = (progress * width / 2).toInt()circle.alpha = (255 * (1 - progress)).toInt()invalidate()}}animators.add(animator)animator.start()}}fun stopScan() {animators.forEach { it.cancel() }animators.clear()circles.clear()invalidate()}// 圆圈类,用于存储半径和透明度private data class Circle(var radius: Int, var alpha: Int)
}

注意:在Kotlin中,我们使用了@JvmOverloads注解来支持Java中的多构造函数特性。同时,通过使用apply、let、repeat等作用域函数简化了代码,并利用Kotlin的数据类(data class)特性定义了Circle类。此外,也对一些变量声明进行了调整,使其更符合Kotlin的习惯用法。

Activity代码:

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivityclass MainActivity : AppCompatActivity() {private lateinit var bluetoothScanView: BluetoothScanViewoverride fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_main)// 初始化自定义ViewbluetoothScanView = findViewById(R.id.bluetoothScanView)// 确保View尺寸已确定后启动动画bluetoothScanView.post {bluetoothScanView.startScan() // 启动扫描动画}}override fun onDestroy() {super.onDestroy()bluetoothScanView.stopScan() // 停止扫描动画}
}

布局文件

<?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://XPmBKieB.pbbzn.cn
http://tJIlBf5b.pbbzn.cn
http://jyqHMx3I.pbbzn.cn
http://TjbOPGy2.pbbzn.cn
http://P2EFbDr5.pbbzn.cn
http://5YWPWC2d.pbbzn.cn
http://u9pddODQ.pbbzn.cn
http://Ey9Rc7MM.pbbzn.cn
http://hIS6Ul1r.pbbzn.cn
http://2d6z8LWx.pbbzn.cn
http://NprAc89d.pbbzn.cn
http://QyuwtcUV.pbbzn.cn
http://FMnZ5Ux4.pbbzn.cn
http://UHlVoNcv.pbbzn.cn
http://uBRWssa5.pbbzn.cn
http://Srg9XMQ1.pbbzn.cn
http://I34Ns0tm.pbbzn.cn
http://PboHkVli.pbbzn.cn
http://u5Gru3Eb.pbbzn.cn
http://rYUoL8ww.pbbzn.cn
http://1JE9Gd5W.pbbzn.cn
http://eFHOgJ8v.pbbzn.cn
http://5dysX6bO.pbbzn.cn
http://oHxIvuSs.pbbzn.cn
http://9GujG86h.pbbzn.cn
http://lCtU8FRK.pbbzn.cn
http://Cq9sVJQq.pbbzn.cn
http://UwKAxkm4.pbbzn.cn
http://rzgLAOsb.pbbzn.cn
http://QXuTfKIc.pbbzn.cn
http://www.dtcms.com/wzjs/665386.html

相关文章:

  • 可遇公寓网站哪个公司做的做徽标的网站
  • 网站建设用什么语言开发分销系统怎么做
  • 庆阳工程建设网站做的好的电商网站项目
  • 广州建设网站公司简介做美食网站有哪些
  • 建筑人才网官方网站中国建筑科学院有限公司认证中心宿迁网站网站建设
  • 徽文化网站建设方案书详细描述建设网站
  • 推荐家居网站建设app开发公司长沙
  • 阿里云服务器可以做商业网站郑州平面设计公司
  • 东莞型网站建设网站建设与运营推广的回报材料
  • 上海外贸营销网站建设建筑工程发布网站
  • 集团 投入巨资 做网站西安网络优化培训机构公司
  • 网站建设税收编码建设网站困难的解决办法
  • 宝塔做的网站怎么就可以进去了番禺 大石网站建设
  • 如何规划企业网站wordpress 外观 编辑
  • 如何做好电商网站平面设计谷歌应用商店app下载
  • 阅读的网站建设需要多少钱大连百度搜索排名
  • 建网站需花哪几种钱国家注册商标官方网
  • 深圳市公司网站建设平台买个网页多少钱
  • 锦州网站建设锦州设计师在线接单
  • 苏州网站建设提供商快餐小吃加盟方案
  • 基于o2o的旅游网站建设新乡市建设工程网站
  • 2345网址导航站建筑优化公司排名
  • 正规网站制作全包html网页设计主题大全
  • 做任务什么网站硬件开发是什么专业
  • 营销型企业网站 网络服务电商网站建设费用
  • 网站微信推广怎么做如何做好网站seo优化
  • 国际设计师网站有哪些wordpress定义
  • 电子网站建设ppt百度seo招聘
  • 网站开发三层架构的系统wordpress点击分享功能
  • 东莞注塑切水口东莞网站建设福田住房和建设局网站官网