360手机卫士—扫描杀雷达效果[通俗易懂]

360手机卫士—扫描杀雷达效果

大家好,又见面了,我是全栈君。

360手机卫士---扫描杀雷达效果[通俗易懂]

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <!-- 背景是雷达图片 -->
        <FrameLayout
            android:layout_width="80dp"
            android:layout_height="match_parent" 
            android:background="@drawable/ic_scanner_malware">
            <ImageView
                android:id="@+id/iv_main_scan"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:src="@drawable/act_scanning_03" />
        </FrameLayout>

        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:orientation="vertical" 
            android:gravity="center_vertical">

            <TextView
                android:id="@+id/tv_main_scan"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="杀毒引擎待命..." />

            <ProgressBar
                android:id="@+id/pb_main_scan"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" 
                
                android:progressDrawable="<span style="color:#ff0000;">@drawable/my_progress</span>"/>
            	<!--  progressDrawable : 指定进度背景和进度图片-->
        </LinearLayout>

    </LinearLayout>

</LinearLayout>

my_progress.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
   
   <!-- 指定进度条的背景图片 -->
    <item android:id="@android:id/background"
        android:drawable="@drawable/security_progress_bg"></item>

    <!-- 指定进度条的进度图片 -->
    <item android:id="@android:id/progress"
        android:drawable="@drawable/security_progress"></item>
</layer-list>

MainActivity.java

package com.atguigu.l10_app;

import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

	private ImageView iv_main_scan;
	private TextView tv_main_scan;
	private ProgressBar pb_main_scan;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		// 旋转的图片
		iv_main_scan = (ImageView) findViewById(R.id.iv_main_scan);
		// 字体提示
		tv_main_scan = (TextView) findViewById(R.id.tv_main_scan);
		// 进度条
		pb_main_scan = (ProgressBar) findViewById(R.id.pb_main_scan);

		// 启动扫描动画
		startScanAnimation();

		// 開始扫描应用
		startScan();
	}

	/**
	 * 启动分线程扫描应用
	 */
	private void startScan() {
		new AsyncTask<Void, Void, Void>() {
			// 更新进度条之前先进行友好提示
			@Override
			protected void onPreExecute() {
				tv_main_scan.setText("開始扫描杀毒!");
			}

			@Override
			protected Void doInBackground(Void... params) {
				int appCount = 100;
				for (int i = 0; i < appCount; i++) {
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					// 通知更新进度条
					publishProgress();
				}
				return null;
			}

			// 同步进度的显示
			protected void onProgressUpdate(Void[] values) {
				pb_main_scan.incrementProgressBy(1);
			}

			// 清除动画效果
			protected void onPostExecute(Void result) {
				tv_main_scan.setText("没有病毒, 请放心使用!");
				Toast.makeText(MainActivity.this, "扫描完毕, 没有发现病毒!", 0).show();
				// 停止扫描动画
				iv_main_scan.clearAnimation();
			}
		}.execute();
	}

	/**
	 * 启动扫描动画
	 */
	private void startScanAnimation() {
		RotateAnimation animation = new RotateAnimation(0f, 360f,
				Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
				0.5f);
		animation.setDuration(1000);
		animation.setRepeatCount(Animation.INFINITE);// 不限定反复次数
		// 旋转的图片启动动画效果
		iv_main_scan.startAnimation(animation);
	}
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/115350.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java线程池参数_java线程池参数设置原则,如何设置线程池参数比较合理?[通俗易懂]

    java线程池参数_java线程池参数设置原则,如何设置线程池参数比较合理?[通俗易懂]线程池的参数应该怎样设置呢?相信对于很多的人来说这也是一个比较难的问题,下面就让我们一起来解决一下,究竟应该如何设置线程池的参数才是最合理的吧!首先在设置参数的时候,有以下的几点是我们需要考虑到的!1、下游系统抗并发的能力多线程给下游系统造成的并发等于你设置的线程数例:假如,是多线程访问数据库,那么就得考虑数据库的连接池大小设置,数据库并发太多影响其qps,会将数据库打挂等问题。假如,是访问下游系…

    2022年5月3日
    49
  • 微信公众平台开发教程Java版(六) 事件处理(菜单点击/关注/取消关注)

    微信公众平台开发教程Java版(六) 事件处理(菜单点击/关注/取消关注)前言:事件处理是非常重要的,这一章讲讲常见的事件处理 1、关注/取消关注 2、菜单点击事件类型介绍:在微信中有事件请求是消息请求中的一种。请求类型为:event 而event事件类型又分多种事件类型,具体分 关注:subscribe 取消关注:unsubscribe 自定义菜单点击:CLICK 根据上面的类型分类可建对应的常量…

    2022年6月22日
    50
  • 【《重构 改善既有代码的设计》学习笔记1】重构:第一个案例「建议收藏」

    【《重构 改善既有代码的设计》学习笔记】重构:第一个案例本篇文章的内容来自《重构 改善既有代码的设计》一书学习笔记整理笔记并且加上自己的浅显的思考总结!一、简单的例子一个影片出租店用的程序,计算每一位顾客的消费金额,并打印详单。详单打印 顾客租了哪些影片、租期多长,影片类型 、单个影片费用、总费用 。 除了费用外,还要计算顾客的积分,不同种类租片积分不同。注:影片为为三类:普通片、儿…

    2022年2月27日
    47
  • mysql查询前十条记录_查询前十条数据

    mysql查询前十条记录_查询前十条数据select*fromno_primary_keyorderbyidlimit10;#显示从id=1到id=10的前10条记录;   select*fromno_primary_keylimit10;#随意显示其中10条记录;   注意:不能用sel来代替select;但是可以用desc来代替describe;

    2025年10月7日
    3
  • chmod 命令——chmod 755与 chmod 4755区别

    chmod 命令——chmod 755与 chmod 4755区别755和4755的区别chmod是Linux下设置文件权限的命令,后面的数字表示不同用户或用户组的权限。一般是三个数字:第一个数字表示文件所有者的权限第二个数字表示与文件所有者同属一个用户组的其他用户的权限第三个数字表示其它用户…

    2022年7月16日
    15
  • idle和pycharm可以同时安装吗_python自带的编辑器

    idle和pycharm可以同时安装吗_python自带的编辑器1、pythonpython自身缺少numpy、matplotlib、scipy、scikit-learn….等一系列重要和常用的包,需要我们安装pip来导入这些包才能进行相应运算(python3.5自带了get-pip.py,不需额外下载安装),在cmd终端输入:pipinstallnumpy就能安装numpy包了。python3.5自带了一个解释器IDLE用来执行.py脚本,但是却不…

    2022年8月28日
    4

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号