How to remove the Activity title from Action Bar Sherlock without losing it from the 'RecentApps' chooser?

梦想与她 提交于 2019-12-14 03:59:52

问题


I am having problems trying to remove the Activity title text from my Action Bar Sherlock. I have spent(wasted) a lot of time trying to find a solution and just cannot make this work.

I have a Splash Activity on which I go full screen. But just before the Splash Activity appears, a screen appears (for a very short period of time) that has nothing but an Action Bar with the App Icon and Activity Title Text. I do not understand why it appears. Is this default Android behavior? I want to avoid this screen, or at least remove the Activity Title from the Action Bar on this screen. If I set it to "", I lose the app from the Recent Apps chooser.

Please refer to these images:

Pre Splash :

Splash Screen :

I have referred to the following examples on SO and also searched elsewhere. But nothing seems to work.

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?

Please check my Android Manifest and the theme file...

<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>

And so on... The following is my theme file:

<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>

I have also written this code in my Splash Activity:

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

    ActivityHelper.initialize(this);

    setContentView(R.layout.activity_splash);

Have I made a mistake that I am overlooking. Is there something else I should do. My minimum API level is 8.

Any help will be appreciated.


回答1:


You can add this to your activity:

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



回答2:


When you first launch your app and Application onCreate haven't finished loading you see the empty lag screen. You can set the window background to green and remove the ActionBar for Application theme, so it will look splash-like.

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>

Make application use splash theme with green background and no 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" />


来源:https://stackoverflow.com/questions/23469730/how-to-remove-the-activity-title-from-action-bar-sherlock-without-losing-it-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!