【问题标题】:splash screen not work with navigation drawer闪屏不适用于导航抽屉
【发布时间】:2017-04-02 11:41:54
【问题描述】:

导航抽屉工作正常,但是当我将启动画面添加到我的项目时它不起作用

splasscreen

清单

【问题讨论】:

  • 请将代码直接添加到您的帖子中,而不仅仅是截图。

标签: navigation drawer splash-screen


【解决方案1】:

我也花了一段时间才解决这个问题。

Android Manifest 中的 Main Activity 应如下所示

Android 清单上的活动部分应如下所示: Note the MainActive Theme

<activity
  android:name=".MainActivity"
  android:label="@string/title_activity_main"
  android:theme="@style/AppTheme.NoActionBar">
</activity>

【讨论】:

  • 非常感谢 Ayo 你节省了我的时间:)
  • 谢谢。这也帮助我节省了时间
【解决方案2】:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nulledapps.website2app">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".SplashScreen"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".MainActivity"></activity>
    </application>

</manifest>

【讨论】:

    【解决方案3】:
    package com.nulledapps.website2app;
    
    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    
    public class SplashScreen extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_splash_screen);
            Thread mythraed = new Thread(){
                @Override
                public void run() {
                    try {
                        sleep(3000);
                        Intent intent = new Intent(getApplicationContext(),MainActivity.class);
                        startActivity(intent);
                        finish();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            };
            mythraed.start();
        }
    }
    

    【讨论】:

      【解决方案4】:

      这段代码对我有用,试试吧:D

      SplashScreen.java 代码:

      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_splash_screen);
      
          new Thread() {
              public void run() {
                  try {
                      sleep(3000);
                      startActivity(new Intent(SplashScreen.this, MainActivity.class));
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          }.start();
      }
      

      }

      AndroidManifest.xml 代码:

      <?xml version="1.0" encoding="utf-8"?>
      

      <uses-permission android:name="android.permission.INTERNET" />
      
      <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=".SplashScreen"
              android:label="TEST"
              android:theme="@style/AppTheme.NoActionBar">
              <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="TEST"
              android:theme="@style/AppTheme.NoActionBar">
          </activity>
      </application>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-08-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多