17

My goal is to show a splash screen on my applications startup. Right now what it will do is briefly show the actionbar with an otherwise blank page, then jump to the splash screen. I'm trying to figure out how to not show the beginning screen and just start with the splash screen. I'm trying to use these links for information on how to solve this.

ActionBar Lag in hiding title In this one I'm assuming I can use the same type of method for hiding the actionbar by changing the theme, but I don't know what I would actually use as my style to do so.

How to hide action bar before activity is created, and then show it again? and here it talks about adding a line to the manifest that would do it. Where in the manifest? Anywhere I put it did not do anything.

Community
  • 1
  • 1
damian
  • 1,419
  • 1
  • 22
  • 41

4 Answers4

38

try this in manifest file

<activity
        android:name="yourActivityName"
        android:label="your label"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen" >

    </activity>
Mohsin Naeem
  • 12,542
  • 3
  • 39
  • 53
  • 1
    How do I get the actionbar back after the splash screen? – damian Jul 11 '12 at 14:25
  • 1
    on which phone you are testing? – Mohsin Naeem Jul 11 '12 at 14:29
  • HTC One XL. That shouldn't matter though. I tried using this.getApplication().setTheme(16973934); to change the theme back but it doesn't do anything – damian Jul 11 '12 at 14:37
  • from which phone I mean to say that which OS...but the reason off crash should not be this..If you remove this line app runs smoothly? – Mohsin Naeem Jul 11 '12 at 14:40
  • Sorry fixed the crash, I was calling a nullPointer when calling getActionBar. It runs fine but I need my actionBar IN the app after the splash screen. Can't figure out how to get it back. – damian Jul 11 '12 at 14:45
  • I think you put this line in Application tag. Just place in `Activity` tag of your splash activity. I also edit my answer..and don't forget to accept the answer if it helps you. – Mohsin Naeem Jul 11 '12 at 14:47
  • Wouldn't android:theme="@android:style/Theme.NoTitleBar" accomplish the same thing? – IgorGanapolsky Jan 31 '13 at 18:25
5

Check this link Android: hide action bar while view load

Code snippets from the link, incase the link breaks down, courtesy @kleopatra:

Setting the properties windowNoTitle to true on your theme will hide the ActionBar. use two different themes both extending parent="Theme.AppCompat.Light" in order to prevent NPE when using getSupportActionBar

set the styles as

<style name="AppThemeNoBar" parent="Theme.AppCompat.Light">
        <item name="android:windowNoTitle">true</item>
</style>
<style name="AppThemeBar" parent="Theme.AppCompat.Light">
        <item name="android:windowNoTitle">false</item>
</style>

Due to some odd behaviour on versions < 11, you need to add

if (Build.VERSION.SDK_INT < 11){ getSupportActionBar().hide(); }

inside activities that do not need the actionbar

Laranjeiro
  • 2,612
  • 3
  • 22
  • 24
  • 1
    Note that [link-only answers are discouraged](http://meta.stackoverflow.com/tags/link-only-answers/info), SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Jan 26 '14 at 11:35
0

Delete the "android:label" entries in Manifest file, from application and the first activity which is loaded. In your case, the Splash activity. Sample...

<application
    android:allowBackup="true"
    android:icon="@drawable/starticon"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo">

    <activity
        android:name=".ActivitySplash"
        android:label="@string/app_name"
        >
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
prototype0815
  • 592
  • 2
  • 7
  • 24
0

Just add this code in your Activity in the onCreate function.

val actionBar = supportActionBar?.apply{hide()}
MöritzRo
  • 11
  • 3