Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
kitkat中的启动屏幕不工作,android中的api级别较低_Android_Splash Screen - Fatal编程技术网

kitkat中的启动屏幕不工作,android中的api级别较低

kitkat中的启动屏幕不工作,android中的api级别较低,android,splash-screen,Android,Splash Screen,我正在android应用程序中使用闪屏。它适用于棒棒糖和更高版本,但不适用于kitkat和更低版本。 问题在menifest.xml中,但我无法修复它 <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round"

我正在android应用程序中使用闪屏。它适用于棒棒糖和更高版本,但不适用于kitkat和更低版本。 问题在menifest.xml中,但我无法修复它

<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/AppTheme">
    <activity android:name=".SplashScreenActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />

        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
}


在res/anim/alpha.xml中

alpha.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromAlpha="0.0"
    android:toAlpha="1.0"
    android:duration="3000" />

这是我的飞溅屏幕。它适用于android 4.1及更高版本


SplashScreen.java

public class SplashScreen extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.splashscreen_layout);

    }

    @Override
    protected void onStart() {

        super.onStart();


        // load your stuff here ...


        Intent intent = new Intent(SplashScreen.this, YourHomeActivity.class);
        startActivity(intent);
        finish();

    }
}

res/layout/splashscreen_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false"
    tools:context=".SplashScreen"
    android:theme="@style/SplashTheme">

</android.support.design.widget.CoordinatorLayout>


  • 6.0(api 23):

  • 显示代码、活动代码我认为menifest.xml文件中没有问题……您可以发布SplashScreenActivity java代码。同时共享您的java代码和xml。如所有建议,请在下面共享您的活动代码checkout java代码
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="false"
        tools:context=".SplashScreen"
        android:theme="@style/SplashTheme">
    
    </android.support.design.widget.CoordinatorLayout>
    
    <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="android:windowBackground">@drawable/splashscreen_drawable</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    </style>
    
    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    
        <item android:drawable="@color/colorPrimary"/>
    
        <item>
            <bitmap
                android:gravity="center"
                android:src="@drawable/your_icon" />
        </item>
    
    </layer-list>
    
    <application
    
            [...]
    
            >
            <activity
                android:name="com.your.package.app.SplashScreen"
                android:label="@string/app_name"
                android:theme="@style/SplashTheme">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    
            [...]