【安卓笔记】仿乐安全首页动态效果

2023-10-16 19:48

本文主要是介绍【安卓笔记】仿乐安全首页动态效果,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

先看效果:


布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"tools:context=".MainActivity" ><FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent" ><ImageViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:src="@drawable/homepage_disk_button_orange_normal" /><ImageViewandroid:id="@+id/iv_rotate"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:src="@drawable/homepage_disk_orange_normal" /><com.example.view.RadiationViewandroid:id="@+id/rv"android:layout_width="250dp"android:layout_height="250dp"android:layout_gravity="center" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:text="SB"android:textColor="#ffffff"android:textSize="30sp" /></FrameLayout>
</LinearLayout>

旋转动画:

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"android:duration="12000"android:fromDegrees="0"android:pivotX="50%"android:pivotY="50%"android:startOffset="0"android:interpolator="@android:anim/linear_interpolator"android:repeatCount="infinite"android:repeatMode="restart"android:toDegrees="360" />

带辐射效果的view:

package com.example.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
/*** @author Rowandjj**带辐射效果的view*/
public class RadiationView extends View
{/***画笔*/private Paint mPaint = new Paint();/***颜色 */private int mColor = 0x3f990e;/*** 透明度*/private int mAlpha = 60;private Handler mHandler = null;private static final int MESSAGE_DRAW = 0;private static final String TAG = "RadiationView";private int width;private int height;/*** 扩散速度*/private int speed = 30;/***最大辐射半径 */private int maxRadius = 100;private int centerX;private int centerY;/*** 最小半径*/private int minRadius = 70;/*** 当前半径*/private int radius = minRadius;private boolean isStarted = false;public RadiationView(Context context){super(context);init();}public RadiationView(Context context, AttributeSet attrs){super(context, attrs, 0);init();}public void startRadiate(){isStarted = true;mHandler.sendEmptyMessage(MESSAGE_DRAW);}private void init(){mPaint = new Paint();mPaint.setStrokeWidth(1);//必须先设置color,再设置alphamPaint.setColor(mColor);mPaint.setAlpha(mAlpha);mHandler = new Handler(){public void handleMessage(android.os.Message msg) {if(msg.what == MESSAGE_DRAW){invalidate();if(isStarted){sendEmptyMessageDelayed(MESSAGE_DRAW,speed);}}}};}@Overrideprotected void onLayout(boolean changed, int left, int top, int right,int bottom){super.onLayout(changed, left, top, right, bottom);width = this.getWidth();height = this.getHeight();if(width <= 0 || height<=0){throw new RuntimeException("size illegal");}//中心点centerX = width/2;centerY = height/2;//最大辐射半径maxRadius = (width > height) ? height/2 : width/2;Log.i(TAG,"MAX"+maxRadius);if(maxRadius < 70){throw new RuntimeException("size too small");}}@Overrideprotected void onDraw(Canvas canvas){mPaint.setColor(mColor);mPaint.setAlpha(mAlpha);if(radius <= 0){return;}if(radius > maxRadius){radius = minRadius;}canvas.save();canvas.drawCircle(centerX, centerY, radius, mPaint);canvas.restore();radius += 1;}@Overrideprotected void onAttachedToWindow(){super.onAttachedToWindow();this.setLayerType(View.LAYER_TYPE_SOFTWARE, null);}public void setColor(int color){this.mColor = color;}public void setSpeed(int speed){this.speed = speed;}public void setMinRadius(int radius){this.minRadius = radius;}
}

调用的代码:

package com.example.animdemo1;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.example.view.RadiationView;
public class MainActivity extends Activity
{private ImageView iv = null;private RadiationView rv = null;@Overrideprotected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);iv = (ImageView) findViewById(R.id.iv_rotate);rv = (RadiationView) findViewById(R.id.rv);rv.setMinRadius(70);//辐射半径rv.startRadiate();//开始辐射Animation anim = AnimationUtils.loadAnimation(this, R.anim.rotate_circle_anim);iv.startAnimation(anim);//开始动画}
}






这篇关于【安卓笔记】仿乐安全首页动态效果的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/220399

相关文章

利用Python快速搭建Markdown笔记发布系统

《利用Python快速搭建Markdown笔记发布系统》这篇文章主要为大家详细介绍了使用Python生态的成熟工具,在30分钟内搭建一个支持Markdown渲染、分类标签、全文搜索的私有化知识发布系统... 目录引言:为什么要自建知识博客一、技术选型:极简主义开发栈二、系统架构设计三、核心代码实现(分步解析

Python从零打造高安全密码管理器

《Python从零打造高安全密码管理器》在数字化时代,每人平均需要管理近百个账号密码,本文将带大家深入剖析一个基于Python的高安全性密码管理器实现方案,感兴趣的小伙伴可以参考一下... 目录一、前言:为什么我们需要专属密码管理器二、系统架构设计2.1 安全加密体系2.2 密码强度策略三、核心功能实现详解

最新Spring Security实战教程之Spring Security安全框架指南

《最新SpringSecurity实战教程之SpringSecurity安全框架指南》SpringSecurity是Spring生态系统中的核心组件,提供认证、授权和防护机制,以保护应用免受各种安... 目录前言什么是Spring Security?同类框架对比Spring Security典型应用场景传统

浅析Rust多线程中如何安全的使用变量

《浅析Rust多线程中如何安全的使用变量》这篇文章主要为大家详细介绍了Rust如何在线程的闭包中安全的使用变量,包括共享变量和修改变量,文中的示例代码讲解详细,有需要的小伙伴可以参考下... 目录1. 向线程传递变量2. 多线程共享变量引用3. 多线程中修改变量4. 总结在Rust语言中,一个既引人入胜又可

安卓链接正常显示,ios#符被转义%23导致链接访问404

原因分析: url中含有特殊字符 中文未编码 都有可能导致URL转换失败,所以需要对url编码处理  如下: guard let allowUrl = webUrl.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) else {return} 后面发现当url中有#号时,会被误伤转义为%23,导致链接无法访问

客户案例:安全海外中继助力知名家电企业化解海外通邮困境

1、客户背景 广东格兰仕集团有限公司(以下简称“格兰仕”),成立于1978年,是中国家电行业的领军企业之一。作为全球最大的微波炉生产基地,格兰仕拥有多项国际领先的家电制造技术,连续多年位列中国家电出口前列。格兰仕不仅注重业务的全球拓展,更重视业务流程的高效与顺畅,以确保在国际舞台上的竞争力。 2、需求痛点 随着格兰仕全球化战略的深入实施,其海外业务快速增长,电子邮件成为了关键的沟通工具。

【学习笔记】 陈强-机器学习-Python-Ch15 人工神经网络(1)sklearn

系列文章目录 监督学习:参数方法 【学习笔记】 陈强-机器学习-Python-Ch4 线性回归 【学习笔记】 陈强-机器学习-Python-Ch5 逻辑回归 【课后题练习】 陈强-机器学习-Python-Ch5 逻辑回归(SAheart.csv) 【学习笔记】 陈强-机器学习-Python-Ch6 多项逻辑回归 【学习笔记 及 课后题练习】 陈强-机器学习-Python-Ch7 判别分析 【学

安全管理体系化的智慧油站开源了。

AI视频监控平台简介 AI视频监控平台是一款功能强大且简单易用的实时算法视频监控系统。它的愿景是最底层打通各大芯片厂商相互间的壁垒,省去繁琐重复的适配流程,实现芯片、算法、应用的全流程组合,从而大大减少企业级应用约95%的开发成本。用户只需在界面上进行简单的操作,就可以实现全视频的接入及布控。摄像头管理模块用于多种终端设备、智能设备的接入及管理。平台支持包括摄像头等终端感知设备接入,为整个平台提

系统架构师考试学习笔记第三篇——架构设计高级知识(20)通信系统架构设计理论与实践

本章知识考点:         第20课时主要学习通信系统架构设计的理论和工作中的实践。根据新版考试大纲,本课时知识点会涉及案例分析题(25分),而在历年考试中,案例题对该部分内容的考查并不多,虽在综合知识选择题目中经常考查,但分值也不高。本课时内容侧重于对知识点的记忆和理解,按照以往的出题规律,通信系统架构设计基础知识点多来源于教材内的基础网络设备、网络架构和教材外最新时事热点技术。本课时知识

2024网安周今日开幕,亚信安全亮相30城

2024年国家网络安全宣传周今天在广州拉开帷幕。今年网安周继续以“网络安全为人民,网络安全靠人民”为主题。2024年国家网络安全宣传周涵盖了1场开幕式、1场高峰论坛、5个重要活动、15场分论坛/座谈会/闭门会、6个主题日活动和网络安全“六进”活动。亚信安全出席2024年国家网络安全宣传周开幕式和主论坛,并将通过线下宣讲、创意科普、成果展示等多种形式,让广大民众看得懂、记得住安全知识,同时还