Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

splash screen application and hide action bar

I'm trying to figure out how is it possible to hide the action bar for a splash screen activity. I did something which hide my action bar on my splash screen, but there is one problem: before my splash screen appears, there is like an activity with an action bar who appears briefly... and I don't know how to hide it!

My splash screen only appears when we touch the application for the first time like an introduction of the application.

Code :

package com.example.basicmaponline;  import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Window;  public class Intro extends Activity{  @Override protected void onCreate(Bundle savedInstanceState) {     // TODO Auto-generated method stub     super.onCreate(savedInstanceState);       getWindow().requestFeature(Window.FEATURE_ACTION_BAR);     getActionBar().hide();      setContentView(R.layout.intro);      Thread timer = new Thread(){         public void run(){             try{                 sleep(3000);             }catch (InterruptedException e) {                 e.printStackTrace();             }finally{                 Intent openMenu = new Intent("com.example.basicmaponline.MENU");                 startActivity(openMenu);             }         }     };     timer.start(); }  @Override protected void onPause() {     // TODO Auto-generated method stub     super.onPause();     finish(); }  } 

Manifest :

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.basicmaponline" android:versionCode="1" android:versionName="1.0" >  <uses-sdk     android:minSdkVersion="11"     android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_GPS"></uses-permission>  <application     android:allowBackup="true"     android:icon="@drawable/lojacidadao"     android:label="@string/app_name"      android:theme="@style/AppTheme">     <activity         android:name="com.example.basicmaponline.Intro"         android:screenOrientation="portrait"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.MAIN" />              <category android:name="android.intent.category.LAUNCHER" />         </intent-filter>     </activity>      <activity         android:name="com.example.basicmaponline.Menu"         android:screenOrientation="portrait"         android:label="@string/app_name">         <intent-filter>             <action android:name="com.example.basicmaponline.MENU" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>      <activity         android:name="com.example.basicmaponline.Mapa"         android:screenOrientation="portrait"         android:label="@string/map_name">         <intent-filter>             <action android:name="com.example.basicmaponline.MAPA" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>     <activity         android:name="com.example.basicmaponline.Lojas"         android:screenOrientation="portrait"         android:label="@string/lojas_name">         <intent-filter>             <action android:name="com.example.basicmaponline.LOJAS" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>      <activity         android:name="com.example.basicmaponline.InfoLoja"         android:screenOrientation="portrait"         android:label="@string/loja_name">         <intent-filter>             <action android:name="com.example.basicmaponline.INFOLOJA" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>      <activity         android:name="com.example.basicmaponline.Balcoes"         android:screenOrientation="portrait"         android:label="@string/balcoes_name" >         <intent-filter>             <action android:name="com.example.basicmaponline.BALCOES" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>      <activity         android:name="com.example.basicmaponline.Entidade"         android:screenOrientation="portrait"         android:label="@string/balcao_name">         <intent-filter>             <action android:name="com.example.basicmaponline.ENTIDADE" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>       <activity         android:name="com.example.basicmaponline.Servicos"         android:screenOrientation="portrait"         android:label="@string/servicos_name">         <intent-filter>             <action android:name="com.example.basicmaponline.SERVICOS" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>       <activity         android:name="com.example.basicmaponline.InfoServico"         android:screenOrientation="portrait"         android:label="@string/servico_name">         <intent-filter>             <action android:name="com.example.basicmaponline.INFOSERVICO" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>       <activity         android:name="com.example.basicmaponline.Pesquisar"         android:screenOrientation="portrait"         android:label="@string/pesquisa_name" >         <intent-filter>             <action android:name="com.example.basicmaponline.PESQUISAR" />              <category android:name="android.intent.category.DEFAULT" />         </intent-filter>     </activity>  </application> </manifest> 
like image 362
Damiii Avatar asked May 29 '13 20:05

Damiii


People also ask

How do I hide action bars?

If you want to hide Action Bar throughout the app (Activities, Fragments) everywhere, you can simply navigate to res > values > styles.

Which method is used to hide the activity title?

The requestWindowFeature(Window. FEATURE_NO_TITLE) method of Activity must be called to hide the title.


Video Answer


2 Answers

why not add to the manifest the theme of the first activity to exclude the action bar, and maybe even the notification bar?

something like:

<application     android:allowBackup="true"     android:icon="@drawable/lojacidadao"     android:label="@string/app_name"      android:theme="@style/AppTheme">     <activity         android:name="com.example.basicmaponline.Intro"         android:screenOrientation="portrait"         android:label="@string/app_name"          android:theme="@android:style/Theme.NoTitleBar.Fullscreen">         <intent-filter>             <action android:name="android.intent.action.MAIN" />              <category android:name="android.intent.category.LAUNCHER" />         </intent-filter>     </activity>  ... 

This should work if you extend the normal Activity class.

If your Activity extends AppCompatActivity instead, use this theme for example:

  <style name="AppTheme.Splash" parent="@style/Theme.AppCompat.NoActionBar">     <item name="android:windowFullscreen">true</item>     <item name="android:windowContentOverlay">@null</item>   </style> 

meaning :

 <activity ...                 android:theme="@style/AppTheme.Splash" >     ... 

BTW, the reason you have the action bar is because you have set the default theme to have it, in the application tag, so it's not an activity before yours, it's really your own splash activity.

like image 58
android developer Avatar answered Oct 01 '22 20:10

android developer


if your build target sdk 5.0 or over (AppTheme style is Theme.AppCompat.Light.DarkActionBar.)

<activity     android:name=".Splash"     android:label="@string/app_name"     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> 
like image 42
Asil ARSLAN Avatar answered Oct 01 '22 20:10

Asil ARSLAN