3
3
import android .app .Activity ;
4
4
import android .app .Dialog ;
5
5
import android .os .Build ;
6
+ import android .view .WindowManager ;
6
7
7
8
import java .lang .ref .WeakReference ;
8
9
@@ -21,7 +22,7 @@ public class SplashScreen {
21
22
/**
22
23
* 打开启动屏
23
24
*/
24
- public static void show (final Activity activity , final int themeResId ) {
25
+ public static void show (final Activity activity , final int themeResId , final boolean fullScreen ) {
25
26
if (activity == null ) return ;
26
27
mActivity = new WeakReference <Activity >(activity );
27
28
activity .runOnUiThread (new Runnable () {
@@ -31,7 +32,9 @@ public void run() {
31
32
mSplashDialog = new Dialog (activity , themeResId );
32
33
mSplashDialog .setContentView (R .layout .launch_screen );
33
34
mSplashDialog .setCancelable (false );
34
-
35
+ if (fullScreen ) {
36
+ setActivityAndroidP (mSplashDialog );
37
+ }
35
38
if (!mSplashDialog .isShowing ()) {
36
39
mSplashDialog .show ();
37
40
}
@@ -46,7 +49,7 @@ public void run() {
46
49
public static void show (final Activity activity , final boolean fullScreen ) {
47
50
int resourceId = fullScreen ? R .style .SplashScreen_Fullscreen : R .style .SplashScreen_SplashTheme ;
48
51
49
- show (activity , resourceId );
52
+ show (activity , resourceId , fullScreen );
50
53
}
51
54
52
55
/**
@@ -89,4 +92,16 @@ public void run() {
89
92
}
90
93
});
91
94
}
95
+
96
+ private static void setActivityAndroidP (Dialog dialog ) {
97
+ //设置全屏展示
98
+ if (Build .VERSION .SDK_INT >= 28 ) {
99
+ if (dialog != null && dialog .getWindow () != null ) {
100
+ dialog .getWindow ().addFlags (WindowManager .LayoutParams .FLAG_LAYOUT_NO_LIMITS );//全屏显示
101
+ WindowManager .LayoutParams lp = dialog .getWindow ().getAttributes ();
102
+ lp .layoutInDisplayCutoutMode = WindowManager .LayoutParams .LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES ;
103
+ dialog .getWindow ().setAttributes (lp );
104
+ }
105
+ }
106
+ }
92
107
}
0 commit comments