Short black screen white screen processing when Android project starts

Source: Internet
Author: User

Just moved from CSDN 51, which was written in 51 in the first blog

So let's talk about such a problem. When your project needs to use the Welcome screen sometimes there will be a short black screen or white screen, so that the user experience is not good, so today teach you how to deal with this problem.

In fact, the black screen or white screen is because the program has not loaded the layout has already shown window Windows background, and the black screen or white screen is the window background. So how to deal with it? Look below ...

public class loadingactivity extends appcompatactivity {          @Override       protected void oncreate (Bundle  savedinstancestate)  {          super.oncreate ( Savedinstancestate);             /* has not yet loaded the layout is sleep 1 seconds, Make sure the black screen or white screen effect is obviously */          try {               thread.sleep (;     )      } catch  (interruptedexception e)  {               e.printstacktrace ();           }             Setcontentview (R.layout.activity_loading)             /* Welcome page for 2 seconds and jump to mainactivity*/           new thread () {                @Override                public void run () {                   try {                        Thread.Sleep (;               )    } catch  (interruptedexception e)  {                        E.printstacktrace ();                   }                   startactivity (new  Intent (Loadingactivity.this,mainactivity.class));                   finish ();               }          }.start ();       }  }

<?xml version= "1.0"  encoding= "Utf-8"? >  <manifest xmlns:android= "http// Schemas.android.com/apk/res/android "      package=" Com.lg.emptydemo ">         <application           android:allowbackup= "true"           android:icon = "@mipmap/ic_launcher"           android:label= "@string/app_ Name "          android:supportsrtl=" true "           android:theme= "@style/apptheme" >           <activity android:name= ". Loadingactivity "              android: Theme= "@style/fulltheme" >              <intent-filter>                   <action android:name= " Android.intent.action.MAIN " />                   <category android:name= "Android.intent.category.LAUNCHER"  / >              </intent-filter>           </activity>           <activity android:name= ". Mainactivity "              android:theme = "@style/apptheme" >          </activity>       </application>    </manifest> 

Set the style of loadingactivity in Androidmanifest.xml

<style name= "Fulltheme"  parent= "AppTheme" >           <item name= "Windowactionbar" >false</item>           <item name= "Android:windowBackground" >@ Drawable/img_frame_background</item>          <item  name= "Windownotitle" >true</item>           <item name= "Android:windowfullscreen" >true</item>           <item name= "Android:windowcontentoverlay" > @null </item>  </ Style> 

Android:windowbackground Property Set the window background and set it to the Welcome screen.

Source Address: http://down.51cto.com/data/2221953

This article is from the "Liuyvhao" blog, make sure to keep this source http://liuyvhao.blog.51cto.com/11690759/1786830

Short black screen white screen processing when Android project starts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.