I have a layout A. When i enter to layout A, i want title app or actionbar will be hide.
i have searched in Google.
<style name="AppTheme.Fullscreen">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
But it must do in AndroidManifest.xml
(My app have many screen, and just only layout A, action bar will hide.)
So, i find a way which can set up it into file layout A?
How can i do that ?
use getSupportActionBar().hide(); to hide your action bar programtically
getSupportActionBar().hide();
if you want fullscreen activity than use below code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
Or you can do it via your AndroidManifest.xml file:
<activity android:name=".YourActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>
Related
In my application i am using an activity as a dialog.Everything works fine but there is one small problem.Whenever the dialog is shown,the title bar is visible.I had done requestWindowFeature(Window.No.Title) but still the title bar is comming.
xml
<style name="CustomDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="android:windowNoTitle">true</item>
</style>
you are using wrong theme
use this
android:Theme.DeviceDefault.Dialog.NoActionBar
also you can hide action bar programmatic .
for that you have to use this in your onCreate mathod
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.hide();
}
How about this ?
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); //before
dialog.setContentView(R.layout.logindialog);
add this before you show the dialog
this answer originally form here
I'm using a custom background for my ActionBar. I followed the tutorial from here.
My styles.xml looks like this:
<resources>
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/actionbar_bg</item>
</style>
</resources>
I want this ActionBar to be displayed on each activity, except the login .. so I hid the ActionBar from my login activity (tut from: stackoverflow):
public class Login extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
In my manifest I added the custom theme ... like this:
<application
android:allowBackup="true"
android:label="#string/app_name"
android:theme="#style/MyTheme"
>
When I run the application, I get the error: You need to use a Theme.AppCompat theme (or descendant) with this activity
So I searched on stackoverflow for a solution. I had to extend Activity instead of ActionBarActivity. I did this, also on my Login Activity.
But now ... I can't hide the ActionBar anymore at my Login activity because it doesnt extend ActionBarActivity anymore .. so the following code:
ActionBar actionBar = getSupportActionBar();
Won't work .. anyone have an idea how to still Hide the actionbar at the Login activity, but still with a working custom Actionbartheme?
TL;DR: I want to use a custom actionbar, but I want to hide it on my Login activity. I can let the actionbar work, but only If I let my Login activity extend from Activity, instead of ActionBarActivity - This causes the getSupportActionBar(); to stop working, So I can't hide the actionbar anymore.
Create a theme whose parent is Theme.Holo.Light.NoActionBar. Assign it to your login activity with android:theme parameter.
Just add below code in onCreate Method before setContentView() method :
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // add this line
setContentView(R.layout.login_layout);
I need to create application wihtout actionbar. I will try to explain how I create application(maybe I am missing some steps).
1.I am intentionally not choosing "Holo Light with Dark Action Bar" option. I thought this make application without action bar.
2.Leaving next page as default:
3.Leaving next page as default:
4.On the next page, it becomes interesting. Blank Activity's description says that it creates a new blank activity an action bar. On Empty Activity's description: Creates a new empty activity. So I choose Empty activity
5.Leaving next page as default.
Result:As usually, application was created with ActionBar.
Tried this solution:getActionBar().hide();. In this solution, ActionBar is hiden after some milliseconds.
Tried to use android:theme="#android:style/Theme.NoTitleBar" in AndroidManifest.xml->application tag. But in this solution, application uses old theme.
My question: how to create Android application without ActionBar using new theme and leaving StatusBar enabled?
PS. I remember, about one year ago, in Eclipse, applications were created without ActionBar. Then we added it manually
Put this right after super.onCreate(savedInstanceState); in the onCreate method of your activity(s):
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Make sure you put this BEFORE this.setContentView(R.layout.activity_example); to avoid crashes
When your project is started you can use public activity extends Activity instead of using ActionBarActivity this will also remove the action bar or there is another way
<android:theme="#android:style/Theme.NoTitleBar">
or you can see these links they might help
How to hide action bar before activity is created, and then show it again?
Remove android default action bar
Refer this code and change as per your requirement:
Update :
styles.xml :
<style name="FullscreenTheme" parent="android:Theme.Holo">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:actionBarStyle">#style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
<item name="android:background">#color/black_overlay</item>
</style>
These will remove actionbar and keeps your theme as it is .
Note : Here i have tested using Theme.Holo . you can use yours.
AndroidManifest.xml
<activity
android:name=".GridViewExample"
android:theme="#style/FullscreenTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
It gives you activity without ActionBar.
Hope this solves your problem.
You can do it programatically:
public class ActivityName extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// remove title
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
Or you can do it via your AndroidManifest.xml file:
<activity android:name=".ActivityName"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>
EDIT :
If your app uses any other theme use corresponding theme name E.g. For White theme #android:style/Theme.Holo.Light.NoActionBar.Fullscreen
In my android project, I wish to disable icon and the title in ActionBar.
Here is the code:
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getActionBar().setDisplayShowTitleEnabled(false);
getActionBar().setDisplayShowHomeEnabled(false);
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
But always on startup they appear and after a while they disappear but i don't want them at all. How can i remove them on startup?
call setDisplayShowHomeEnabled(false) and setDisplayShowTitleEnabled(false) on your ActionBar.
actionBar.setDisplayUseLogoEnabled(false); should do it.
Or
For Splashscreen you should use this line in manifest and don't use getActionBar()
<item name="android:windowActionBar">false</item>
and once when Splash Activity is finished in the main Activity use below or nothing
<item name="android:windowActionBar">true</item>
Reffer this ----> click here
You can use below code for that -
<activity android:name="YourActivityname" android:theme="#android:style/Theme.NoTitleBar" />
If you want the full screen of your device you can use below code -
<activity android:name="YourActivityname" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" />
And, also refer Developer's Site
Another method
Do this in your onCreate() method.
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here);
this refers to the Activity.
Maybe this answer can help you. It helped me.
<quote>
Best method is to set the display options to useLogo in your theme. E.g.
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions">useLogo</item>
</style>
This won't actually show the logo (if set) because showHome is not included.
</quote>
try this:
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
setContentView(R.layout.activity_main);
}
NOTE: The getActionBar() method was added in Honeycomb (API: 11) and later
Anyone know how to disable/hide notification bar at the top which show battery and other things in android.
Any help will be appreciated.
EDIT: Please also add how can I hide ActionBar+NotificationBar for later android versions.
You could use a theme in your AndroidManifest.xml:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
or change parent of your AppTheme to #android:style/Theme.NoTitleBar.Fullscreen like this
<style name="AppTheme" parent="Theme.NoTitleBar.Fullscreen">
</style>
then apply this theme on activities which you want Fullscreen like
android:theme="#style/AppTheme"
or use the following code snippet:
public class FullScreen
extends android.app.Activity
{
#Override
public void onCreate(android.os.Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
}
}
The answers above hide ActionBar too.
If you intend to only hide notification bar, use this code:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
be careful to put it before setContentView().
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
Another Simple option is to add <item name="android:windowFullscreen">true</item> on the theme you will apply to activities that don't need a notification bar...
like so..
<style name="AppTheme.Splash">
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">#drawable/background_splash</item>
</style>
Works like charm
Successfully implemented a slightly modified version of #Martin's suggestion along with a custom theme to get rid of BOTH the Status and Navigation Bar.
public class MyActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//* Hides Notification Bar
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_my);
}
Top part is used to get rid of the Status bar. Add the following code to your #styles as a resource to kill off the NavBar as well.
<resources> <style name="NoNav" parent="#android:style/Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style> </resources>
After you add this to your resource file, pop open AndroidManifest.xml and chance your application theme to "#style/NoNav".
Android UI bloatware eliminated :)
You can use this for 4.1 or upper versions.
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
you can do like this in onCreate() method :
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getActionBar();
actionBar.hide();
This answer is for android developers who like minimalist and simplified one-liner code. If you intend to only hide notification bar, use this code:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
be careful to put it before setContentView() in your on create() function of required activity.class