Hide Notification Bar in Custom Theme Android - android

I have designed a Custom Theme for my android application.
I want the application to go fullscreen but also display the TitleBar.
I want to hide/disable the NotificationBar but retain the TitleBar.
I tired this code. But this hides the TitleBar instead of the NotificationsBar.
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
Add this code to your Android Manifest.xml

Related

Android fullscreen activity with action bar

what theme should I use to hide the notification bar but show the action bar? (Like calculator on Samsung phones)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Use this with Theme holo
**you have to do it through coding add this before setContentView() **

Activity Full Screen in Android

I am trying to make like Trello application, see in the screenshot of Trello, they covered complete screen with background but still time, network show in title bar, I want to do same in my application such that set background to complete full screen and should show network and time.
I am trying this but it didn't work for me.
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
}
Update
Removing the action bar
You can hide the action bar at runtime by calling hide(). For example:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
https://developer.android.com/guide/topics/ui/actionbar.html
For a translucent system bar (like in trello) see this:
Translucent system bars
You can now make the system bars partially translucent with new
themes, Theme.Holo.NoActionBar.TranslucentDecor and
Theme.Holo.Light.NoActionBar.TranslucentDecor. By enabling translucent
system bars, your layout will fill the area behind the system bars, so
you must also enable fitsSystemWindows for the portion of your layout
that should not be covered by the system bars.
If you're creating a custom theme, set one of these themes as the
parent theme or include the windowTranslucentNavigation and
windowTranslucentStatus style properties in your theme.
http://developer.android.com/about/versions/android-4.4.html#UI
try this:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,windowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Android introduced a Immersive Full Screen Mode concept from Android 4.4, here you can see https://developer.android.com/training/system-ui/immersive.html that solved my problem.

Hide Status Bar In Non Rooted Device

How to hide status bar of tab in non rooted device? I am Using Android 4.0.4
I used like this but it is not working for me...please suggest any solution
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// hide titlebar of application
// must be before setting the layout
requestWindowFeature(Window.FEATURE_NO_TITLE);
// hide statusbar of Android
// could also be done later
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
did you change the theme in android manifest like below,
android:theme="#android:style/Theme.Black.NoTitleBar"
I did some researches about this problem a while ago. I could not find a solution to realize this in a non rooted device.
The best I could do is to dim the status bar as follows:
setContentView(R.layout.activity_main);
getWindow().getDecorView().setSystemUiVisibility( View.STATUS_BAR_HIDDEN ); // dim System bar
FLAG_FULLSCREEN flag doesnt do it anymore! Seems for security reasons, Google want it to always show, so that the user can press home button, etc ...
I am still wondering how applications like MX Player have made it possible.
Hope this helps!

Hide status bar on android

I am trying to hide the status bar. I have tried the following things.
This is for phones. I realize tablets can be different. It does hide the status bar when the layout has a bottom Tab. any ideas?
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
In the Manifest.XML I have added the above code.
And in the onCreate() I have added the followingin the right place:
requestWindowFeature(Window.FEATURE_NO_TITLE);
// hide statusbar of Android
// could also be done later
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

android how to hide the status bar without hiding the title bar

In my application i am working with canvas. I am drawing on canvas. I put canvas color as white. When my app open the canvas is visible along with above status bar.
But i want my canvas should take the full screen. means that Notification status bar should disapear when i run that app bt not the title bar(bcz i m using some custom title bar)
How can i do that?
By using below code i gave custom title,
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
Now i am trying to hide status bar using below code in activity-
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
and in AndroidManifest.xml
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
But it shows force close.
Give me a way how to do that?
It's enough to remove the line
requestWindowFeature(Window.FEATURE_NO_TITLE);
But if you want to display full screen (without action bar) write too
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_location_eb);
You can't use Window.FEATURE_CUSTOM_TITLE after setting Theme.NoTitleBar. It's enough to use just this theme. Do not set all these flags in code.
EDIT: Seems I misunderstood your question. I read it again carefully and now I see you're asking about Android 2.x and its notification bar. Your onCreate() method should look like this:
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.name);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
You mustn't set Theme.NoTitleBar or Theme.NoTitleBar.Fullscreen for this activity. Just use the default Theme or don't specify any theme at all.
Am going to tell you how to tackle the title bar and the system notification panel individually and perfectly.
Use one or both as per Your Need.
1.Do not apply any theme to the Activity through XML.
2.Now, go the corr. Java file and add these lines
inside onCreate()..
after super.onCreate()..
Part.a. to remove just Title Bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Part.b. to remove the System notification panel
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Do not forget to follow them with the usual
setContentView(R.layout.activity_layout_name);

Categories

Resources