實現(xiàn)一個歡迎界面的動畫,即打開app顯示的頁面,動畫結(jié)束后跳到Activity。
1、歡迎界面的背景是一個綠色矩形
2、歡迎界面的布局,整個布局的背景為上面的綠色矩形背景,此外包括兩個TextView
3、歡迎界面的動畫
是逐漸縮小,淡出的效果,動畫持續(xù)4000毫秒
4、在WelcomActivity.java中加載頁面布局和動畫,
public?void?onAnimationEnd(Animation?animation)//在動畫結(jié)束后跳轉(zhuǎn)到MainActivity
//WelcomActivity.java
package?com.sunny.csdnblog; import?android.app.Activity; import?android.os.Bundle; import?android.os.Handler; import?android.view.Window; import?android.view.animation.AnimationUtils; import?android.view.animation.Animation; import?android.view.animation.Animation.AnimationListener; import?android.content.Intent; import?android.view.View; import?android.widget.ImageView; import?android.widget.TextView; public?class?WelcomActivity?extends?Activity{ private?Handler?mHandler; @Override protected?void?onCreate(Bundle?savedInstanceState){ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.welcom_layout); mHandler?=?new?Handler(); //TextView?welcomTextView?=?(TextView)findViewById(R.id.welcomImage); //TextView?madebyTextView?=?(TextView)findViewById(R.id.madeby); View?welcomView?=?(View)findViewById(R.id.welcom_layout); Animation?animation?=?AnimationUtils.loadAnimation(this,?R.anim.welcom_anim); animation.setAnimationListener(new?AnimationListener(){ @Override public?void?onAnimationStart(Animation?animation)?{ //?TODO?Auto-generated?method?stub } @Override public?void?onAnimationEnd(Animation?animation)?{ //?TODO?Auto-generated?method?stub mHandler.post(new?Runnable(){ @Override public?void?run()?{ //?TODO?Auto-generated?method?stub Intent?intent?=?new?Intent(WelcomActivity.this,MainActivity.class); startActivity(intent); WelcomActivity.this.finish(); } }); } @Override public?void?onAnimationRepeat(Animation?animation)?{ //?TODO?Auto-generated?method?stub } }); welcomView.startAnimation(animation); //madebyTextView.startAnimation(animation); } }
5、MainActivity顯示一個頁面head和一個WebView
public?class?MainActivity?extends?FragmentActivity?{ private?WebView?webView; @Override protected?void?onCreate(Bundle?savedInstanceState)?{ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); webView?=?(WebView)findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new?WebViewClient()); webView.loadUrl("http://blog.csdn.net/doudoulee_blog"); } }