White/black screen when APP starts or white/black screen when Activity is opened

To draw the entire window, you need to perform the following steps in order: 

1. Draw the background. 

2. Draw the content of the View itself. 

3. Draw the child View. 

4. Draw decoration content (such as scroll bars).

In Themethe window you can specify the background Activityof ICON, APP overall text color, etc., if no attributes are specified, it will use default property , so our black and white and black and empty DecorViewclosely, Style we decided to set the APP Is it a white screen or a black screen.

1. If Blackthe theme of the selected series is selected, the Activityscreen will be black when jumping:

@android:style/Theme.Black"
 
  
  
  • 1
  • 1

2. If Lightthe theme of the selected series is selected, the Activityscreen will be blank when jumping:

@android:style/Theme.Light"

Solution

The usual solution is to Activityset a transparent background theme:

<style name="SplashTheme" parent="AppTheme">
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowIsTranslucent">true</item>
</style>
  
   
   
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

After the above setting, when the APP and Activitystartup, our StartingWindowtheme will be applied with our transparent background. There is indeed no white or black screen when jumping, but this setting will have the following consequences:

1. SplashActivityAfter setting, after the user clicks on our APP icon, the contentView will be displayed after about 2 seconds. This creates the illusion that the APP starts slowly Activity, but it has already started, but it backgroundis transparent. At this time, clicking on other places on the desktop is invalid. This runs counter to the original intention of Google, so we must continue to look down. 
2. After setting other activities, overridePendingTransitionthe animation of closing the activity through the set start and close will be invalid. Need to rewrite the following animations in style:

<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowAnimationStyle">@style/Animation.Activity.Translucent.Style</item>
<item name="android:windowFullscreen">true...
<item name="android:windowIsTranslucent">true...
</style>

<style name="Animation.Activity.Style" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">...
<item name="android:activityOpenExitAnimation">...
<item name="android:activityCloseEnterAnimation">...
<item name="android:activityCloseExitAnimation">...
</style>

<style name="Animation.Activity.Translucent.Style" parent="@android:style/Animation.Translucent"> 
<item name="android:windowEnterAnimation">...
<item name="android:windowExitAnimation">...
</style>  
  
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

3、Activity之间的跳转可能偶尔会看到桌面一闪而过(如果SplashActivity和其他Activity都设置了透明)。



Guess you like

Origin blog.csdn.net/xifei66/article/details/77092610