android App冷启动优化

       android App冷启动优化,实现点击App Logo,立马又相应,而且不会白屏和黑屏;优化用户体验!

 

参考:https://www.cnblogs.com/xunzhi/p/5794793.html
    
    第一步:launcher_background.xml (drawable)
            
            
            

                
                        

                
                
                
                
                    
                
                
            
            
    第二步:styles.xml
            
            

            
            

            
    第三步:manifest.xml
    
                             ……………………
                android:theme="@style/AppTheme"
                ………………>
                
                             android:theme="@style/AppTheme.Launcher"
                android:screenOrientation="portrait">
                
                    

                    
                
            
            
    第四步:activity_welcome.xml
    
            设置启动页面的背景为透明色:(因为启动页面已经设置了theme背景,所以这里再次设置背景多余,也有可能拉伸图片的效果)
            
            
                             android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/transparent">

            
    
    第五步:MainActivity.java
    
            @Override
            protected void onCreate(Bundle savedInstanceState) {

                // 冷启动优化后重新设回原来的主题
                setTheme(R.style.AppTheme);

                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_welcome);
            }

 

 

android studio,使用flutter开发,冷启动优化的处理:

    1》、flutter工程,对android studio已经做过处理的;在style.xml里:
    
    
        
        
            

        
        
    2》、在对应的 launch_background.xml里:
    
        
        
        
            
            
        

你可能感兴趣的:(android)