Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtAndroid::hideSplashScreen() not working



  • Question

    Can't QtAndroid::hideSplashScreen() according to this:
    https://stackoverflow.com/questions/51351146/how-to-create-a-splash-screen-using-qml

    Code

    Create the splash resource in android/res/drawable/splash.xml. Something like

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
        <item>
            <shape android:shape="rectangle" >
                <solid android:color="#ffffff"/>
            </shape>
        </item>    <item>
            <bitmap
                android:gravity="center"
                android:src="@drawable/app"/>
        </item>
    </layer-list>
    

    Create a theme in android/res/values/apptheme.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="AppTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar">
            <item name="android:background">@drawable/splash</item>
            <item name="android:statusBarColor">#ffffff</item>
        </style>
    </resources>
    

    In android/AndroidManifest.xml find the activity element and add this attribute: android:theme="@style/AppTheme" Add these:

    <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
    <meta-data android:name="android.app.splash_screen_sticky" android:value="true"/>
    

    In .pro file add

    QT += androidextras
    

    In C++ code:

    QtAndroid::hideSplashScreen(250);
    

    Environment

    Qt 5.15.1
    

Log in to reply