android12 default splash screen page transparent
Two ways:
- App entry activity theme theme add the following items
<!-- 闪屏页透明 跳转该activity相当于弹出dialog(悬浮窗口) -->
<item name="android:windowIsTranslucent">true</item>
Note:
- Add the above item to the style of the entry activity in styles.xml to make the splash screen transparent
- After adding this attribute, there will be side effects: When A activity jumps to the B application (entry activity) with this attribute added, B application will be displayed on top of A activity in the form of a floating pop-up dialog, and A activity will go onPause() , will not go onStop()
- Determine whether diolog will affect the current activity life cycle:
- The dialog popped up by the activity itself will not go through the life cycle
- The pop-up theme is that the activity of the dialog will use the onPause() method, not onStop()
- Framework layer: hide it or set the transparency to 0 when adding a splash screen view
+++ b/frameworks/base/libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/StartingSurfaceDrawer.java
@@ -320,6 +320,12 @@ public class StartingSurfaceDrawer {
// if view == null then creation of content view was failed.
if (contentView != null) {
try {
+ if (activityInfo.packageName.equals("com.demo.demo")){
+ contentView.setAlpha(0.0F);
+ contentView.setVisibility(View.INVISIBLE);
+ }
rootLayout.addView(contentView);
} catch (RuntimeException e) {
Slog.w(TAG, "failed set content view to starting window "