The reason and solution of black screen or screen when Android app starts _android

Source: Internet
Author: User

1, the cause

In fact, the display of black screen or white screen is normal, because it has not been loaded into the layout file, it has been shown window windows background, Black Screen screen is window windows background.

Example:

2. Solutions

Set style by setting

(1) Setting the background figure theme

By setting a background picture. When the program starts, first display this background image to avoid the black screen

<style name= "Apptheme" parent= "Theme.AppCompat.Light.DarkActionBar" >
    <item name= "Android: Screenorientation ">portrait</item>
    <item name=" Android:windowbackground ">> @mipmap/splash </item>
    <item name= "android:windowistranslucent" >true</item>
    <item name= "Android: Windownotitle ">true</item>
</style>
 

(2) Set up transparent theme

By setting the style to transparent, the program does not start black screen but the whole is transparent, wait until the interface is initialized to display it once

<style name= "Apptheme" parent= "Theme.AppCompat.Light.DarkActionBar" >
    <item name= "Android: Windownotitle ">true</item>
    <item name=" Android:windowbackground "> @android: Color/transparent </item>
    <item name= "android:windowistranslucent" >true</item>
    <item name= "Android: Screenorientation ">portrait</item>
  </style>

Comparison between the two:

The THEME1 program starts fast, the interface first displays the background image, and then refreshes the other interface controls. Give people a refreshing feeling of not being synchronized.
Theme2 gives the program start slow feeling, the interface brushes out once, refreshes the synchronization.

(3) Modify Androidmanifest.xml

<application
    android:name= ". App "
    android:allowbackup=" true "
    android:icon=" @mipmap/ic_launcher "
    android:label=" @string/app_name "
    android:supportsrtl=" true ">
    <activity android:name=". Mainactivity "
     android:theme=" @style/apptheme ">
      <intent-filter>
        <action android:name=" Android.intent.action.MAIN "/>

        <category android:name=" Android.intent.category.LAUNCHER "/>"
      </intent-filter>
    </activity>

  /

... </application>

Example after resolution:

3, the common theme theme

Android:theme= "@android: Style/theme.dialog"//activity displayed as dialog box mode

Android:theme= "@android: Style/theme.notitlebar"//Do not display the application title bar

Android:theme= "@android: Style/theme.notitlebar.fullscreen"//Do not display the application title bar and full screen

Android:theme= "Theme.light"//Background is white

Android:theme= "Theme.Light.NoTitleBar"//white background with no title bar

Android:theme= "Theme.Light.NoTitleBar.Fullscreen"//white background, no title bar, full screen

Android:theme= "Theme.black"//Background Black

Android:theme= "Theme.Black.NoTitleBar"//black background with no title bar

Android:theme= "Theme.Black.NoTitleBar.Fullscreen"//black background, no title bar, full screen

Android:theme= "Theme.wallpaper"//with System desktop for application background

Android:theme= "Theme.Wallpaper.NoTitleBar"//with System desktop for application background with no title bar

Android:theme= "Theme.Wallpaper.NoTitleBar.Fullscreen"//with System desktop for application background, no title bar, full screen

Android:theme= "theme.translucent"//Transparent Background

Android:theme= "Theme.Translucent.NoTitleBar"//Transparent background with no title

Android:theme= "Theme.Translucent.NoTitleBar.Fullscreen"//Transparent background with no title, full screen

Android:theme= "Theme.panel"//panel style display

Android:theme= "Theme.Light.Panel"//Flat style display

The above is the Android app startup black screen or screen reasons and solutions to the data collation, follow-up to continue to supplement the relevant information, thank you for your support for this site!

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.