How to avoid black screen in android while my app is loading?

后端 未结 4 868
无人共我
无人共我 2020-12-15 12:01

How to avoid black screen in android while my app is loading ? I have removed all things from onCreate to AsyncTask but still I have black screen at the beginning. My defa

相关标签:
4条回答
  • 2020-12-15 12:04

    i'm not sure.

    but, Try this in Manifest inside your activity

    android:theme="@android:style/Theme.Translucent" 
    

    Or

    android:theme="@android:style/Theme.Light"
    

    I have seen a good solution about splash screen... hope it useful

    https://stackoverflow.com/a/8654361/762919

    0 讨论(0)
  • 2020-12-15 12:17

    Since you have cleared out your onCreate() and assigned your initialization tasks to a worker thread, the fact that your screen nonetheless remains dark for a while after your app is launched is probably due to the complexity of the graphics in your initial display (rather than to your initialization code, which is probably model-related, rather than view-related).

    The solution that you say worked for you is to use a visible background as your theme. I'm glad that you found that to be adequate, but for some purposes a more specific (e.g., logo / app name) splash screen (which displays quickly because it uses much simpler graphics) would be more desirable.

    Please see the answer linked below for a detailed description (with sample code) of how a splash screen that displays quickly can be implemented:

    Create a true splash screen

    This also discusses the approach that you have accepted above.

    0 讨论(0)
  • 2020-12-15 12:24

    Add below line in your android style.xml file in style tag .

     <item name="android:windowDisablePreview">true</item>
    

    Complete code :

     <style name="AppBaseTheme" parent="android:Theme.Light.NoTitleBar">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
        <item name="android:windowDisablePreview">true</item>
    </style>
    
    0 讨论(0)
  • 2020-12-15 12:28

    Optimize ur code,try to reduce code from onCreate(),this was issue faced by me i solved it by reducing code in onCreate().

    Best of Luck

    0 讨论(0)
提交回复
热议问题