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


相关推荐

  • 火狐的Http请求插件的安装和使用[通俗易懂]

    火狐的Http请求插件的安装和使用[通俗易懂]火狐有一个http请求插件,安装之后就可以用它来测试各种http请求了(GET/POST/PUT/DELETE)。安装步骤如下:1、打开火狐的附加组件管理器2、在左边菜单栏选择插件3、在搜索栏搜索httpRequest4、选择并安装,然后重启浏览器5、以上步骤完成后,在浏览器右上角就已经出现该插件了6、点击它即可打开,然后就可以模拟http请求了…

    2022年6月15日
    69
  • 微信小程序页面跳转 回退页面api

    微信小程序页面跳转 回退页面api小程序如果 跳转url后 需要直接返回首页或者回退之前好几个页面,跳转url时用 wx.redirectTo设置好回退的参数即可。如果返回上一页时 跳转url时用 wx.navigateTo

    2022年8月19日
    3
  • 什么是系统平均负载(Load average)

    什么是系统平均负载(Load average)一、什么是系统平均负载(Loadaverage)?在Linux系统中,uptime、w、top等命令都会有系统平均负载loadaverage的输出,那么什么是系统平均负载呢?LoadAver

    2022年7月3日
    20
  • excel旭日图_旭日图怎么画

    excel旭日图_旭日图怎么画旭日图(Sunburst)由多层的环形图组成,在数据结构上,内圈是外圈的父节点。因此,它既能像饼图一样表现局部和整体的占比,又能像矩形树图一样表现层级关系。引入相关文件旭日图是ApacheEChartsTM4.0新增的图表类型,从CDN引入完整版的echarts.min.js最简单的旭日图创建旭日图需要在series配置项中声明类型为‘sunburst’的系列,并且以树形结构声明其data:varoption={series:{type

    2022年9月25日
    0
  • elevator saga游戏下载_win10玩沙滩ZERO特别卡

    elevator saga游戏下载_win10玩沙滩ZERO特别卡一,游戏介绍这是一个在线编写JS代码的游戏:http://play.elevatorsaga.com/显示界面:其中的doc是肯定要看的。操作界面:初始代码:{init:function(elevators,floors){varelevator=elevators[0];//Let’susethefirstelevator//Whenevertheelevatorisidle(has..

    2022年9月18日
    0
  • 从源码角度看JedisPoolConfig参数配置

    做一个积极的人编码、改bug、提升自己我有一个乐园,面向编程,春暖花开!你好,JedisPoolConfigJava中使用Jedis作为连接Redis的工具。在使用Jedis的也可以配置JedisPool连接池,JedisPool配置参数大部分是由JedisPoolConfig的对应项来赋值的。本文简单总结几个常用的配置,然后通过源码(版本jedis-3.1.0)的角度让你理解配置这些…

    2022年2月28日
    59

发表回复

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

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