为 Android 应用程序添加启动页的步骤如下:

  1. 用XML编辑器打开 “AndroidManifest.xml”,在文件里添加如下内容:

    <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
    • 其中“splash”就是程序启动页面的图片。添加后的文件结果大概如下:
    <?xml version="1.0"?>
    <manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
        <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@drawable/icon" android:theme="@style/MyAppTheme">
            <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
                ...
    
                <!-- Splash screen -->
    
                <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
    
                <!-- Splash screen -->
    
                ....
            </activity>
        </application>
        <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/>
        <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
    
        <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
             Remove the comment if you do not require these default permissions. -->
        <!-- %%INSERT_PERMISSIONS -->
    
        <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
             Remove the comment if you do not require these default features. -->
        <!-- %%INSERT_FEATURES -->
    
    </manifest>
  2. 分别在项目路径 “./android/res” 目录下 drawable-* 文件夹 (“drawable-ldpi”、“drawable-mdpi”和“drawable-hdpi”等)下添加一个“splash,png”图片,图片名称一定要和第一步的名称一样。

标签: Qt, Android, 启动页

添加新评论