首页 > 解决方案 > Android闪屏跳转java

问题描述

我想以正确的方式实现启动屏幕 - 没有表面延迟,仅在应用程序执行一些实际工作时显示它。所以我搜索了很多并找到了以下解决方案:我将主题应用于 SplashActivity,处理逻辑并打开下一个活动。问题是闪屏有点跳。尝试了不同的选项 - 全屏,没有用于启动的操作栏,没有用于启动和跟随活动的操作栏,android:windowDrawsSystemBarBackgrounds true\false 和其他几个。如果我将延迟设置为 115-150 毫秒,那么 10 个案例中有 9 个没有跳跃。问题是如何摆脱跳跃并保持初始屏幕精简。

飞溅活动:

public class SplashActivity extends CheckForInternetActivity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        routeActivity();
    }

安卓清单:

    <activity
        android:name="ru.awac.CBoRrates.SplashActivity"
        android:screenOrientation="portrait"
        tools:ignore="LockedOrientationActivity"
        android:theme="@style/AppTheme.SplashScreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

样式.xml:

 <style name="AppTheme.SplashScreen" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/splash_screen</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

闪屏:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:opacity="opaque">
    <item android:drawable="@android:color/white"/>
    <item>
        <bitmap
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:adjustViewBounds="true"
            android:scaleType="fitCenter"
            android:layout_margin="5dip"
            android:src="@drawable/awac_presents_transparent_1" />
    </item>

</layer-list>

awac_presents_transparent_1 只是一个 png

跳跃的 Youtube 视频

标签: javaandroidxmlsplash-screen

解决方案


推荐阅读