1、启动页LunchActivity必须继承Activity
public class LunchActivity extend Activity{
}
2、manifests配置文件为LunchActivity设置主题
android:theme="@android:style/Theme.Translucent.NoTitleBar"
<activity
android:name=".LunchActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
3、超简单的android启动白屏解决方案搞定
4、实现全面屏沉浸式的
class LunchActivity : Activity() {
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
val decorView = window.decorView
val uiOptions = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)
decorView.systemUiVisibility = uiOptions
}
}
override fun onCreate(savedInstanceState: Bundle?) {
requestWindowFeature(Window.FEATURE_NO_TITLE)
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
val lp = this.window.attributes
lp.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
super.onCreate(savedInstanceState)
}
}