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!
Related
Does any body have idea about how to hide system bar in android and make it visible only when swiping up on the screen. Other wise it remains hidden all the time. I got code for hide the system bar when the activity loading first time. When I am touching on the screen it become visible and stays always visible, system bar is not hiding till another activity loads. Please Help.
Thanks in advance
Just make full screen activity in eclipse...and rest will done by android..
First of all, to do this your application would have to be full screen or rooted.And it all depends on the Android Version you are using. For Android 4.0 and lower, you can use this in your manifest:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
Alternatively, you can programmatically set WindowManager flags. This approach makes it easier to hide and show the status bar as the user interacts with your app:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If the Android version is lower than Jellybean, use this call to hide
// the status bar.
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.activity_main);
}
...
Go to the developer site for more on this. I'd also visit this SO question for more in-depth information
I'm a beginner android developer and one of the problems that I am facing is how to make my application full screen.
I have used the:
"android:theme=”#android:style/Theme.NoTitleBar.Fullscreen"
But it actually just removes the status and the action bar, but it keeps the navigation bar.
I tried various different methods without any success, but I know that it's possible since I have lots of apps the do not show the navigation bar like Subway Surfers.
Which is the right way to make it?
Add the following code to your activity:
public class YourActivity extends Activity {
#Override
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.your_layout);
...
}
}
p.s.:
Add the following to your onResume() method:
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(uiOptions);
Note that it is not possible to remove the navigation bar in all cases (see docs: "it does not hide the system bar on tablets"). Starting from 4.4 on you could enable Immersive Mode. Check out this post related to Android 3.0 devices ("You cannot hide the system bar on Android 3.0.").
// Erase the title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Make it full Screen
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(int windowConstVal) is a method to call on Activity and always you to use a Constant from the Window class that applies a variety of additional features to the window.
getWindow().addFlags() Get the window reference from the current activity and add flags (more features) use a Constant from the windowManager class.
You could create a SurfaceView, but it depends on what you want to do if it is useful or not. If you want to make a game, it would probably be useful, but since you might want to use things like Buttons or labels, you can either hide it like described in other answers, or use it (since it gives you an optionMenu with it).
in the end it comes down to what you want to do
In your Manifest, you add this line, but you add in between the activity tags that are already there.
Here is the line: android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
This should be working,there is no reason not to,I am sure of that since I recently used this.
I am trying to hide the status bar. I have tried the following things.
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 following:
requestWindowFeature(Window.FEATURE_NO_TITLE);
// hide statusbar of Android
// could also be done later
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
But still I am unable to hide the status bar. Can anyone help?
The approaches you've taken would work on 2.3.X
But if you are talking about 4.0 tablets this is the code
LinearLayout layout = (LinearLayout)findViewById(R.id.layout);
layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
If you're talking about a tablet you cannot get rid of the system bar but I suggest you look at this question:
Hide Status bar on Android Ice Cream Sandwich
Just make sure that you are writing above code lines before the line setContentView()?
How do I hide the android 4.0 mini pc combined bar or Status bar programatically?
I am using the below code, but it is not working.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
just set android:theme="#android:style/Theme.NoTitleBar.Fullscreen" attribute on your activity in the manifest file. Sometimes programmatic window manipulations can get messy. Try this out.
Go to settings->Display->hide status bar tick that to hide
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);