文章目錄
- 前言
- 一、歡迎頁
- 總結
前言
好久沒發博客了,最近太忙了
提示:以下是本篇文章正文內容,下面案例可供參考
一、歡迎頁
代碼如下(示例):
public class WelcomeMainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);//隱藏狀態欄
getSupportActionBar().hide();//隱藏標題欄
//\實作改功能可以使用以下4種方式
//1.sleep() 2.handler 發送延遲訊息 3.Timer類 4.使用影片\
//使用影片實作 alpha:透明 利用0.7f到1.0f過渡的程序中制造幾秒的停頓
ObjectAnimator animator = ObjectAnimator.ofFloat(findViewById(R.id.welcome_img),"alpha",0.7f,1.0f);
//設定影片執行時間
animator.setDuration(2000);
//影片啟動
animator.start();
//監聽影片是否結束
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
startActivity(new Intent(WelcomeMainActivity.this,MainActivity.class));
}
});
}
}
XML中的代碼就設定了一張圖片
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/welcome_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/welcome"
tools:context=".WelcomeMainActivity"/>
總結
以上就是歡迎頁的實作了.如果有誤的東西,我會盡量去改的
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/281668.html
標籤:其他
