【发布时间】: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