标签:tin nba ati etc 引擎 idt utf-8 protected androi
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); //1. 显示扫描动画 showScanAnimation(); //2. 扫描,并显示扫描进度 scan(); } /** * 扫描,并显示扫描进度 */ private void scan() { //启动异步任务做 new AsyncTask<Void, Void, Void>() { //1. 主线程, 显示提示视图 protected void onPreExecute() { tv_main_scan.setText("手机杀毒引擎正在扫描中..."); } //2. 分线程, 做长时间的工作(扫描应用) @Override protected Void doInBackground(Void... params) { int appCount = 60; //设置进度条的最大值 pb_main_scan.setMax(appCount); for(int i=0;i<appCount;i++) { SystemClock.sleep(40); //扫描完成一个 //发布进度 publishProgress(); } return null; } //在主线程执行, 更新进度 protected void onProgressUpdate(Void[] values) { pb_main_scan.incrementProgressBy(1);//增加1 //pb_main_scan.setProgress(pb_main_scan.getProgress()+1); } //3. 主线程, 更新界面 protected void onPostExecute(Void result) { //隐藏进度条 pb_main_scan.setVisibility(View.GONE); //更新文本 tv_main_scan.setText("扫描完成, 未发现病毒应用, 请放心使用!"); //停止扫描动画 iv_main_scan.clearAnimation(); } }.execute(); } /** * 显示扫描动画 * iv_main_scan的旋转动画 */ private void showScanAnimation() { //创建动画对象 RotateAnimation animation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); //设置 animation.setDuration(1000); animation.setRepeatCount(Animation.INFINITE); animation.setInterpolator(new LinearInterpolator()); //启动 iv_main_scan.startAnimation(animation); } }
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="手机杀毒" android:background="#FFCFCE" android:textSize="25sp" android:gravity="center" android:padding="5dp"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <FrameLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:background="@drawable/ic_scanner_malware"> <ImageView android:id="@+id/iv_main_scan" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/act_scanning_03" /> </FrameLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center_vertical" android:layout_marginLeft="10dp"> <TextView android:id="@+id/tv_main_scan" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /> <ProgressBar android:id="@+id/pb_main_scan" style="?android:attr/progressBarStyleHorizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:progressDrawable="@drawable/my_progress"/> </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>
标签:tin nba ati etc 引擎 idt utf-8 protected androi
原文地址:https://www.cnblogs.com/znsongshu/p/9365339.html