Android App FullScreen - android

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.

Related

Non-deprecated way to hide status bar on android?

I have seen two ways to disable the status bar. Both of them are deprecated.
The first one from the documentation:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
The other one from here, for example:
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
In the first method setSystemUiVisibility is deprecated, and in the second method WindowManager.LayoutParams.FLAG_FULLSCREEN is deprecated. What is a non-deprecated/current way to hide the status bar on android? I'd prefer a method which hides the status bar throughout the app, not just in one activity.
You could use this:
FrameLayout frameLayout = findViewById<FrameLayout>(R.id.mainView)
frameLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
for the new android version, where R.id.mainView is your main layout.
Please check this for more details: https://proandroiddev.com/exploring-windowinsets-on-android-11-a80cf8fe19be

how to hide the status bar from all layouts?

I want to hide the statusbar from all layouts on click of button.That button i have define in setting layout. But on click of hide button the status bar of current layout is getting hide but on other layout is unaffected.So let me know how to implement it on all the layouts of mu app.
Create a superclass for all Activities, call it something like BaseActivity or AbstractActivity and make each activity extend this class
In the onCreate, before setContentView, read from a database like SharedPreferences whether the status bar should be hidden. If so, then hide it.
In your Settings activity, call recreate() so that each onCreate from the previous activities are called again.
It actually depends on the version of android you are using. For example in Android 4.0 and lower you can achieve it by doing:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
For full documentation go to: https://developer.android.com/training/system-ui/status
Edit: What would be better for your button is this code:
void HideStatusBar() {
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
}
So, when the user clicks the button call this function. Remember this also hides the action bar or toolbar, so if you don't want that remove the actionbar.hide() part. It's nice, but unfortunately, it only works on Android 4.1 and higher, so if you are supporting lower versions too better look at the documentation for clues. Hope it helps!

How to hide system bar and make visible only on touching screen in android

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

Keep Navigation Bar hidden

I am writing a fullscreen application, and I need to KEEP the navBar hidden,
I am using View.SYSTEM_UI_FLAG_HIDE_NAVIGATION But the bar will reappear as soon as there is an interaction from the user,
I found some other questions, but none have the answer ... so have anyone succeeded ?
Thank you in advance
Add the following line under your activity in Manifest File and it will make you r activity full screen
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
You can't hide completely NavigationBar, it will ALWAYS reappear after user interaction.
Would be nice if you posted what you have already tried.
I use this to temporarily hide my actionbar:
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
getActionBar().hide();
The code is at the beginning of onCreate
Using only View.SYSTEM_UI_FLAG_HIDE_NAVIGATION, the first touch event is consumed by the system, and the navigation bar will reapear.
If you are coding for KitKat(4.4.2) onwards, you can add this code to your onResume() method:
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
Read more about Immersive Mode: https://developer.android.com/training/system-ui/immersive.html
This works for me.
http://www.androiddocs.com/training/system-ui/immersive.html
From the post:
The flags SYSTEM_UI_FLAG_IMMERSIVE and SYSTEM_UI_FLAG_IMMERSIVE_STICKY both provide an immersive experience, but with the differences in behavior described above. Here are examples of when you would use one flag vs. the other:
If you're building a book reader, news reader, or a magazine, use the IMMERSIVE flag in conjunction with SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION. Because users may want to access the action bar and other UI controls somewhat frequently, but not be bothered with any UI elements while flipping through content, IMMERSIVE is a good option for this use case.
If you're building a truly immersive app, where you expect users to interact near the edges of the screen and you don't expect them to need frequent access to the system UI, use the IMMERSIVE_STICKY flag in conjunction with SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION. For example, this approach might be suitable for a game or a drawing app.
If you're building a video player or some other app that requires minimal user interaction, you can probably get by with the lean back approach, available since Android 4.0 (API Level 14). For this type of app, simply using SYSTEM_UI_FLAG_FULLSCREEN and SYSTEM_UI_FLAG_HIDE_NAVIGATION should be sufficient. Don't use the "immersive" flags in this case.

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!

Categories

Resources