手機殺毒進度條特效

來源:互聯網
上載者:User

標籤: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>

 

手機殺毒進度條特效

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.