【问题标题】:Android emulator won't load when splash screen is added添加启动画面时,Android 模拟器不会加载
【发布时间】:2021-06-11 15:56:14
【问题描述】:

因为模拟器不会加载。当我将themes.xml中的Splash主题更改为直接链接到徽标(而不是@drawable/splash_background,这是一个间接调用徽标的.xml文件)时,模拟器会加载,但启动画面仍然不显示.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.settheme">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.SetTheme">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:theme = "@style/Splash">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.example.settheme.SecondActivity"/>
    </application>

</manifest>

themes.xml

<resources xmlns:tools="http://schemas.android.com/tools">
    <!-- Base application theme. -->
    <style name="Theme.SetTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <!-- Primary brand color. -->
        <item name="colorPrimary">@color/purple_500</item>
        <item name="colorPrimaryVariant">@color/purple_700</item>
        <item name="colorOnPrimary">@color/white</item>
        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
        <!-- Customize your theme here. -->
    </style>
    <style name="Splash">
        <item name="android:windowDisablePreview" parent="Theme.AppCompat.NoActionBar">true</item>
        <item name="android:windowBackground">@drawable/splash_background</item>
    </style>
</resources>

【问题讨论】:

    标签: android android-emulator splash-screen


    【解决方案1】:

    我认为您需要添加新的空活动,女巫给您两个文件>>一个用于您的“splashscreen.java”代码和“splashscreen_main.xml”,然后添加您的启动画面 java 代码并将您的徽标添加到“splashscreen_main.xml”。 xml'通过添加它像图像,不要忘记在你的'AndroidManifest.xml'中访问它然后尝试agin,如果我理解你的问题,那么先这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-02
      • 2015-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-16
      • 1970-01-01
      • 2021-10-22
      相关资源
      最近更新 更多