-
主要目的
欢迎页面大多是一张图片,其中要隐藏状态栏、ActionBar,针对有些机型还要隐藏导航栏
-
activity_splash.xml
在欢迎页面放一张图片
<ImageView
android:id="@+id/image"
android:src="@drawable/splash_image"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
-
SplashActivity.java
全屏显示
private void fullScreen(){
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
继承Thread重写run()方法
@Override
public void run() {
try {
sleep(2000);//休眠
} catch (InterruptedException e) {
e.printStackTrace();
}
//跳转
Intent intent = new Intent(getApplicationContext(),MainActivity.class);
startActivity(intent);
finish();
}
-
修改manifest文件
设置为NoActionBar
android:theme="@style/Theme.AppCompat.NoActionBar"
下面是针对存在导航栏机型一个隐藏导航栏的方法
这样就简单实现了欢迎界面
PS:还有一些其他的功能,比如:点击跳过,多页面滑动等等,在今后的学习过程中慢慢改进。