我需要在我的蜂窝应用程序中实现启动画面。 我在activity的onCreate中使用这段代码来显示splash:

setContentView(R.layout.splash);
getActionBar().hide();

这段代码将显示主UI:

setContentView(R.layout.main);
getActionBar().show();

但在onCreate被调用和飞溅出现之前,有一小段时间,当动作栏显示。

我怎样才能使动作栏不可见?

我尝试将主题应用于没有动作条的活动:

<item name="android:windowActionBar">false</item>

但在这种情况下,getActionBar()总是返回null,我发现没有办法再次显示它。


当前回答

这可能很方便 把这个加到你的舱单上

 android:theme="@android:style/Theme.Light.NoTitleBar" 

干杯

其他回答

只需将其添加到您的styles.xml中

<item name="android:windowNoTitle">true</item>

在阅读了所有可用选项后,我发现最好的方法是设置主主题而不使用ActionBar,然后在所有活动的父级代码中设置MyTheme。

清单:

<application
...
        android:theme="@android:style/Theme.Holo.Light.NoActionBar"
...>

BaseActivity:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTheme(R.style.GreenHoloTheme);
}

这种方法可以帮助我在应用程序启动时避免使用ActionBar !

我还试图在Android 2.2上隐藏操作栏,但这些解决方案都不起作用。一切都以崩溃告终。我检查了DDMS日志,它告诉我使用“Theme.AppCompat”。最后,我通过改变android:theme="@android:style/ theme . holo . light . noactionbar "行解决了这个问题

为android:主题= " @style / Theme.AppCompat。NoActionBar”,它工作,但界面是黑暗的。

然后我尝试了android:theme="@style/ theme . appcompat . light。NoActionBar”,最终得到了我想要的。

之后,当我在开发者网站上搜索“AppCompat”时,我得到了这个。

所以我认为Android 2.2的解决方案是

<activity
    android:name=".MainActivity"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

对我的英语很抱歉,一如既往。

最好和简单

requestWindowFeature (Window.FEATURE_NO_TITLE); getWindow () .setFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

你可以用这个:

getSupportActionBar () hide ();如果不奏效,试试下面这个:

getActionBar().hide();

如果以上都不行,试试下面的方法:

在你的目录= res/values/style.xml,打开style.xml ->有属性父更改为父="Theme.AppCompat.Light.DarkActionBar"

如果这一切都不奏效。我也不知道了。但对我来说很管用。