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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • maven本地有包却加载失败_maven configuration problem

    maven本地有包却加载失败_maven configuration problem[INFO]BUILDFAILURE[ERROR]Failedtoexecute[ERROR]Formoreinformationabouttheerrorsandpossiblesolutions,pleasereadthefollowingarticles:1、问题情形项目代码是从SVN上刚下载的。同事在启动项目时,程序卡在下图这个地方不…

    2026年1月20日
    7
  • anaconda tensorflow pycharm_tensorflow搭建

    anaconda tensorflow pycharm_tensorflow搭建目录安装anaconda安装pycharm安装tensorflowpycharm新建有tensorflow模块的Project目前正在学习tensorflow库的深度学习的一些知识,基本的安装和环境配置做个记录。安装anaconda到官网上下载安装,ana2和ana3都可以,我这里都下载了。安装时候注意勾选写入路径。安装到某个盘,以后的环境会在那里生成。安装pycharm到官网上下载安装…

    2022年8月27日
    7
  • clion 激活码【2021免费激活】

    (clion 激活码)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~https://javaforall.net/100143.htmlIntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,上面是详细链接哦~9A…

    2022年3月22日
    45
  • 下载文件总结

    下载文件总结

    2021年9月20日
    74
  • Git教程 git pull 和 git clone的区别

    Git教程 git pull 和 git clone的区别.

    2022年7月21日
    11
  • spel表达式的用法_el表达式判断是否为空

    spel表达式的用法_el表达式判断是否为空spel表达式运算使用翻看公司代码,这一块不是很懂,查资料,记一下,还是太菜1.常用的对象Expression:表达式对象SpelExpressionParser:表达式解析器EvaluationContext:上下文2.使用本文参考了下面的几篇文章https://www.cnblogs.com/shihuc/p/9338173.htmlhttps://blog.csdn.net/f641385712/article/details/90812967下面的例子主要是来源于第一

    2025年9月6日
    6

发表回复

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

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