如何从Action Bar Sherlock中删除活动标题,而不会从' RecentApps'中删除它。选择器?

时间:2014-05-05 10:00:32

标签: android actionbarsherlock

我在尝试从Action Bar Sherlock删除活动标题文字时遇到问题。 我花了很多时间(浪费)试图找到一个解决方案,但却无法使其发挥作用。

我有一个Splash Activity我全屏显示。但是在Splash Activity出现之前,会出现一个屏幕(在很短的时间内),除了包含App IconActivity Title文本的操作栏外,其他任何内容都只显示。我不明白为什么会出现。这是默认的Android行为吗?我想避开此屏幕,或者至少从此屏幕上的操作栏中删除活动标题。如果我将其设置为“”,则会从最近的应用选择器中丢失该应用。

请参考以下图片:

Pre Splash:

启动画面:

我在SO上提到了以下例子,并在其他地方搜索过。但似乎没有任何效果。

Remove the title text from the action bar in one single activity

Action Bar remove title and reclaim space

How do you remove the title text from the Android ActionBar?

How can I remove title and icon completetly in Actionbar sherlock?

请检查我的Android Manifest和主题文件......

<application
    android:name="com.zipcash.zipcashbetaversion.MyApplication"
    android:allowBackup="true"
    android:icon="@drawable/zipcash_icon"
    android:label="@string/app_name"
    android:logo="@drawable/zipcash_logo_small"
    android:theme="@style/Theme.MyTheme" >
    <activity
        android:name="com.zipcash.zipcashbetaversion.SplashActivity"
        android:label="@string/app_name" 
        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="com.zipcash.zipcashbetaversion.SignUpActivity"
        android:label="@string/title_activity_sign_up"  
        android:screenOrientation="portrait" >
    </activity>

依旧...... 以下是我的主题文件:

<style name="Theme.MyTheme" parent="Theme.Sherlock.Light">

    <!-- Set style for Action Bar (affects tab bar too) -->
    <item name="actionBarStyle">@style/Widget.MyTheme.ActionBar</item>
</style>

<style name="Widget.MyTheme.ActionBar" parent="Widget.Sherlock.ActionBar">

    <!-- define background for action bar (sets default for all parts of action bar - main, stacked, split) -->
    <item name="android:background">@drawable/background</item>
    <item name="background">@drawable/background</item>

    <!-- set background for the tab bar (stacked action bar) - it overrides the background property -->
    <item name="backgroundStacked">@color/action_bar_tab_background</item>
    <item name="titleTextStyle">@style/NoTitleText</item>
    <item name="subtitleTextStyle">@style/NoTitleText</item>
    <item name="displayOptions">showHome|useLogo</item>
</style>

<style name="NoTitleText">
    <item name="android:textSize">0sp</item>
    <item name="android:textColor">#00000000</item>
    <item name="android:visibility">invisible</item>
</style>

我还在我的Splash Activity中编写了这段代码:

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.hide();

    ActivityHelper.initialize(this);

    setContentView(R.layout.activity_splash);

我犯了一个我忽略的错误。还有什么我应该做的。我的最低API级别为8。

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:3)

您可以将此添加到您的活动中:

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >

答案 1 :(得分:0)

当您首次启动应用并且应用程序onCreate尚未完成加载时,您会看到空滞后屏幕。您可以将窗口背景设置为绿色并删除ActionBar for Application主题,因此它看起来像飞溅一样。

colors.xml

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

    <color name="splash_background">#86bf3a</color>

</resources>

styles.xml

<style android:name="SplashTheme" parent="@style/Theme.Sherlock.Light.NoActionBar">

    <item name="android:windowBackground">@color/splash_background</item>

</style>

使应用程序使用带有绿色背景且没有ActionBar

的初始主题
<application
    ...
    android:theme="@style/SplashTheme" >

    <activity
        android:name="com.zipcash.zipcashbetaversion.SplashActivity"
        ....>

        <!-- .... -->

    </activity>


        <!--...
             make all other Activities use MyTheme
        ...-->    


    <activity
        android:name="com.zipcash.zipcashbetaversion.SignUpActivity"
        ...
        android:theme="@style/Theme.MyTheme" />