Reputation: 17930
I've developed a simple demo application with a splash screen a map and some regular screens.
I have an action bar at the top that contains a logo. It all looks fine on my phone (Galaxy s1 I9000 V2.3) but when i test it on Galaxy s2 v4 the action bar appears also in the splash screen and in the map screen.
The spalsh and map activity are not even inheriting from ActionBarActivity so how is that possible and how can i make it go away?
Manifest:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:theme="@style/Theme.AppCompat.Light" >
<activity
android:name=".HomeActivity"
android:icon="@drawable/android_logo"
android:label=""
android:logo="@drawable/android_logo" >
<!--
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
-->
</activity>
<activity
android:name=".MapActivity"
android:label="" >
</activity>
<activity
android:name=".PackageActivity"
android:icon="@drawable/android_logo"
android:label=""
android:logo="@drawable/android_logo" >
</activity>
<activity
android:name=".SplashActivity"
android:label="" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
MapActivity definition (it's a long one so i included just the definition):
public class MapActivity extends FragmentActivity implements LocationListener
Splash Activity:
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
public class SplashActivity extends Activity{
private static final long SPLASH_DISPLAY_LENGTH = 2000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
Intent mainIntent = new Intent(SplashActivity.this,HomeActivity.class);
SplashActivity.this.startActivity(mainIntent);
SplashActivity.this.finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
}
Upvotes: 131
Views: 233833
Reputation: 31
getsupportactionbar.hide();
100% it's will work any version android studio based on java language.
Upvotes: 1
Reputation: 9225
Apply the following in your Theme for the Activity in AndroidManifest.xml
:
<activity android:name=".Activity"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 145
Reputation:
@Override
public void onResume() {
super.onResume();
getSupportActionBar().hide();
}
@Override
public void onStop() {
super.onStop();
getSupportActionBar().show();
}
Upvotes: 4
Reputation: 101
If you activity extends AppCompatActivity then you can add this line super.getSupportActionBar().hide(); before setContentView()
Upvotes: 1
Reputation: 341
For selectively hiding Actionbar in activities:
Add the following code to onCreate (preferably on the last line of the function)
Kotlin:
supportActionBar?.hide()
Java:
getSupportActionBar().hide();
Upvotes: 3
Reputation: 25
First cheek MainActivity for activity tag,Like -
public class MainActivity extends AppCompatActivity
Then goto menifest xml file and write-
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
in activity tag
Upvotes: 0
Reputation: 169
To hide the ActionBar add this code into java file.
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
Upvotes: 9
Reputation: 41749
The ActionBar
usually exists along Fragments
so from the Activity
you can hide it
getActionBar().hide();
getActionBar().show();
and from the Fragment
you can do it
getActivity().getActionBar().hide();
getActivity().getActionBar().show();
Upvotes: 18
Reputation: 1
Check for padding attribute if the issue still exists after changing theme.
Padding Issue creating a white space on top of fragment window / app window
Once you remove the padding - top value automatically the white space is removed.
Upvotes: 0
Reputation: 11
Add New Style in your style.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="LoginTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
and then add following line in your manifest
<activity android:name=".Login"
android:label="@string/app_name"
android:theme="@style/LoginTheme"
>
Upvotes: 1
Reputation: 133
Replace AndroidManifest.xml
android:theme="@style/FullscreenTheme"
to
android:theme="@style/Theme.Design.NoActionBar"
Upvotes: 0
Reputation: 19385
As you are asking about how to hide in a certain activity, this is what you need :
getSupportActionBar().hide();
Upvotes: 174
Reputation: 59
Apply the following in your Theme for the Activity in AndroidManifest.xml:
<activity android:name=".DashboardActivity"
android:theme="@style/AppFullScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Then Apply the following in your Style in style.xml
<style name="AppFullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
Upvotes: 5
Reputation: 1690
From here:
Beginning with Android 3.0 (API level 11), all activities that use the default theme have an ActionBar as an app bar. However, app bar features have gradually been added to the native ActionBar over various Android releases. As a result, the native ActionBar behaves differently depending on what version of the Android system a device may be using. By contrast, the most recent features are added to the support library's version of Toolbar, and they are available on any device that can use the support library.
So one option is to disable ActionBar completely (in the app manifest.xml file) and then add Toolbar in every page that needs an ActionBar.
(follow the above link for step-by-step explanation)
Upvotes: 1
Reputation: 578
This works for me! Put this in your Activity in manifests
<activity
// ...
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
// ...
</activity>
You can also make your custom theme in styles.xml like this:
<style name="Theme.MyCustomTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name = "android:windowActionBar">false</item>
<item name = "android:windowNoTitle">true</item>
// more custom...
</style>
Hope this help.
Upvotes: 9
Reputation: 4082
This works in API 27
In the styles.xml replace code to the following....
<resources>
<!-- No Action Bar -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Then in the files (eg. activity_list.xml) in which you do want to have a toolbar put the following code.
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/colorPrimary"/>
If you have problems switch to linear layout (because that is what this code is tested on)
Upvotes: 1
Reputation: 6246
You can use Low Profile mode See here
Just search for SYSTEM_UI_FLAG_LOW_PROFILE
that also dims the navigation buttons if they are present of screen.
Upvotes: 5
Reputation: 223
The above answers would help with the ActionBar thing. To add to it, use the following code in case you are using the Splash Screen: Use this before you set the content view:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Just to clarify, here's how you do it:
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
This would make your screen a full screen, i.e remove the top bar where you see the network bar, etc
Upvotes: 4
Reputation: 6178
If you want to get full screen without actionBar and Title.
Add it in style.xml
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
and use the style at activity of manifest.xml.
<activity ....
android:theme="@style/AppTheme.NoActionBar" > ......
</activity>
Upvotes: 32
Reputation: 4646
If you were using Theme.AppCompat.Light, a better equivalent would be Theme.AppCompat.Light.NoActionBar.
I found that using Theme.AppCompat.NoTitleBar caused my button text to be invisible so I am using Theme.AppCompat.Light.NoActionBar.
<activity android:name=".Activity"
android:label="@string/app_name"
android:theme="@android:style/Theme.AppCompat.Light.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 8
Reputation: 4067
1.Go to your manifest.xml
file.
2.Find
the activity tag
for which you want to hide your ActionBar and then add
,
android:theme="@style/Theme.AppCompat.NoActionBar"
<activity
android:name=".MainActivity"
android:theme="@style/Theme.AppCompat.NoActionBar"
>
Upvotes: 47