Splashscreen与Android中的支持操作栏配合不完善

Splashscreen与Android中的支持操作栏配合不完善,android,splash-screen,Android,Splash Screen,我在安卓系统中有一个带有抽屉布局的支持操作栏应用程序,还有一个应用程序的启动屏幕 问题是当我启动我的应用程序时,ActionBar会在启动屏幕前闪烁一秒钟 我该如何解决这个问题 以下是我的启动屏幕代码: public class SplashScreen extends ActionBarActivity { // Splash screen timer private static int SPLASH_TIME_OUT = 3000; @Override

我在安卓系统中有一个带有抽屉布局的支持操作栏应用程序,还有一个应用程序的启动屏幕

问题是当我启动我的应用程序时,ActionBar会在启动屏幕前闪烁一秒钟

我该如何解决这个问题

以下是我的启动屏幕代码:

public class SplashScreen extends ActionBarActivity {

    // Splash screen timer
    private static int SPLASH_TIME_OUT = 3000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
        getSupportActionBar().hide();
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.splash_activity);

        new Handler().postDelayed(new Runnable() {

            /*
             * Showing splash screen with a timer. This will be useful when you
             * want to show case your app logo / company
             */

            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start your app main activity
                Intent i = new Intent(SplashScreen.this, ZMainActivity.class);
                startActivity(i);

                // close this activity
                finish();
            }
        }, SPLASH_TIME_OUT);
    }

}
这是我的舱单:

    <activity
        android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
        android:label="MeriMasjid.com"
        android:screenOrientation="portrait" >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    </activity>

请注意,我不能为我的活动使用任何主题,因为它是一个应用程序兼容应用程序

解决方案:

 <activity
    android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
    android:label="MeriMasjid.com"
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.NoTitleBar">
    >

将ActionBarActivity转换为Splashscreen的Activity,并将@android:style/Theme.NoTitleBar应用到其在清单中的条目中,工作正常

问题是,转到
oncreate
方法使您的活动全屏显示需要时间,因此
actionbar
会在消失前闪烁片刻

而是以编程方式将其应用到清单中,而不是在活动标记中

示例:

 <activity
    android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
    android:label="MeriMasjid.com"
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.NoTitleBar">
    >
在您的清单中添加此项后:

 <activity
    android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
    android:label="MeriMasjid.com"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme">
    >

>

问题在于,转到
oncreate
方法需要时间才能使您的活动全屏显示,因此
操作栏在消失之前会闪烁片刻

而是以编程方式将其应用到清单中,而不是在活动标记中

示例:

 <activity
    android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
    android:label="MeriMasjid.com"
    android:screenOrientation="portrait"
    android:theme="@android:style/Theme.NoTitleBar">
    >
在您的清单中添加此项后:

 <activity
    android:name="info.androidhive.androidsplashscreentimer.SplashScreen"
    android:label="MeriMasjid.com"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme">
    >

>

仅仅因为您使用AppCompat并不意味着每个活动都需要扩展
ActionBarActivity
——只有那些需要操作栏的活动才应该扩展
ActionBarActivity
。对于启动屏幕,您可以扩展
活动
(如果您不需要任何片段)或
片段活动
(如果您确实需要片段)。在任何一种情况下,你都可以毫无例外地使用android:style/Theme.NoTitleBar等样式。

仅仅因为你使用AppCompat,并不意味着每个活动都需要扩展
ActionBarActivity
——只有那些需要操作栏的活动才应该扩展
ActionBarActivity
。对于启动屏幕,您可以扩展
活动
(如果您不需要任何片段)或
片段活动
(如果您确实需要片段)。在这两种情况下,您都可以毫无例外地使用诸如
@android:style/Theme.NoTitleBar
之类的样式。

如果您希望actionbat低于11,则需要AppCompat。如果您不想要,那么就不要使用appcompat。此外,actionbar还可以从api级别11本机获得。如果您希望actionbat低于11,则需要AppCompat。如果您不想要,那么就不要使用appcompat。此外,actionbar在api级别1106-24 09:10:42.991:E/AndroidRuntime(7814):致命异常:main 06-24 09:10:42.991:E/AndroidRuntime(7814):java.lang.RuntimeException:无法启动活动组件信息{com.example.qiblaclean/info.androidhive.AndroidPlashCreentimer.SplashsScreen}:java.lang.IllegalStateException:此活动需要使用Theme.AppCompat主题(或子代)。幸运的是,此操作不起作用。得到相同的错误修复了问题!!请参阅更新06-24 09:10:42.991:E/AndroidRuntime(7814):致命异常:main 06-24 09:10:42.991:E/AndroidRuntime(7814):java.lang.RuntimeException:无法启动活动组件信息{com.example.qiblaclean/info.androidhive.AndroidPlashCreentimer.SplashScreen}:java.lang.IllegalStateException:您需要使用Theme.AppCompat主题(或子代)与此活动关联。幸运的是,此操作不起作用。出现相同的错误修复了此问题!!请参阅更新