開機動畫 看圖學Android---Android 開發執行個體教程五

來源:互聯網
上載者:User

標籤:android 開發執行個體教程 零基礎學習   開機動畫   

Android執行個體圖解教程目錄

http://blog.csdn.net/wyx100/article/details/45061407

 

在《開發一個新的android介面、介面跳轉 看圖學Android---Android 開發執行個體教程三、四》基礎完成開機動畫,開機介面的圖片,在5.5秒內逐漸消失,顯示主介面。

只修改StartActivity.java中代碼以下部分

StartActivity.java原始碼

package com.example.helloword;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.view.animation.AlphaAnimation;import android.view.animation.AnimationSet;import android.widget.ImageView;public class StartActivity extends Activity {/** Called when the activity is first created. */ private final int SPLASH_DISPLAY_LENGHT = 3000; //延遲三秒   private ImageView image=null;@Overridepublic void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.start);            image=(ImageView)findViewById(R.id.imageView1);        AnimationSet  animationset=new AnimationSet(true);        AlphaAnimation alphaAnimation=new AlphaAnimation(1, 0);//AlphaAnimation(1, 0)圖片逐漸層成透明,1指透明度為0%,0指透明度100%        alphaAnimation.setDuration(5500);        animationset.addAnimation(alphaAnimation);        image.startAnimation(animationset);    new Handler().postDelayed(new Runnable(){               @Override         public void run() {             Intent mainIntent = new Intent(StartActivity.this,MainActivity.class); //介面跳轉定義            StartActivity.this.startActivity(mainIntent); //啟動介面跳轉             StartActivity.this.finish(); //介面跳轉完成後,消除介面一        }                   }, SPLASH_DISPLAY_LENGHT); //介面一顯示時間長度}}

 

 

開機動畫 看圖學Android---Android 開發執行個體教程五

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.