i am new in android programming!
i want a full screen image like Hill Climb Racing (as you can see below)
i try to use
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
but it just disappear action bar and i want to disappear both action bar and android default key bar (home button, back and the another one)
If you are targeting android 4.0 and higher
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
Check this developer site for more detail information
try this in your activity on the manifest
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
Related
The following code successfully hides the system's navigation bar from the screen. Users can still swipe up to reveal the navigation bar, which will remain on screen for a few seconds, then disappear again.
Is there a callback to detect when the navigation bar appears and disappears, as the user swipes up, and afterwards, when the navigation bar automatically hides?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
getWindow().setDecorFitsSystemWindows(false);
if (getWindow().getInsetsController() != null) {
getWindow().getInsetsController().hide(WindowInsets.Type.navigationBars());
getWindow().getInsetsController().setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
}
} else {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
);
}
The code below (taken from the docs) seems to detect when the navigation bar is hidden on launch, but not when the user swipes up to reveal it, or when it disappears afterwards.
View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener
(new View.OnSystemUiVisibilityChangeListener() {
#Override
public void onSystemUiVisibilityChange(int visibility) {
// Note that system bars will only be "visible" if none of the
// LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
// TODO: The system bars are visible. Make any desired
// adjustments to your UI, such as showing the action bar or
// other navigational controls.
} else {
// TODO: The system bars are NOT visible. Make any desired
// adjustments to your UI, such as hiding the action bar or
// other navigational controls.
}
}
});
Is there a callback to detect when the navigation bar appears and disappears, as the user swipes up, and afterwards, when the navigation bar automatically hides?
You can't detect that, a user's swipe to show the navigation bar or the status bar isn't a part of your app, it's the system responsibility that runs in a different process than your app's.
Actually your app's window isn't affected on that swipe; and hence the bars are laid on top of your activity (without any extra insets) and that is an evidence that it's related to the system window instead. So, any listener within your app's process/window can't help on that.
Check this answer for more detail.
I'm making a custom keyboard for android, full screen, i want to hide the navigation bar and the status bar on Android only when keyboard is shown and then return the same state.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
}
Use the above given code to hide the status bar from the app. Also, don't forget to apply your keyboard visible condition.
I want to make my top status bar transparent using below code, which make status bar transparent but also make bottom navigation bar transparent.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); // in Activity's onCreate() for instance
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
// w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
I want to make bottom navigation bar opaque like below.
I want to make only status bar transparent not bottom navigation bar. So please help me as i am new in android
Although it work nice in kitkat as below i want, but not above kitkat.
It can be done using
<item name="android:navigationBarColor">#color/theme_color</item>
or
window.setNavigationBarColor(#ColorInt int color)
http://developer.android.com/reference/android/view/Window.html#setNavigationBarColor(int)
will work for API level 21+
I'm developing a app for a specific tablet running android 4.4.4. Users aren't allowed to close the app. I hoped there was a way to completely hide or disable the navigation bar but I can't seem to find a solution. I've already tried to use the method explained on Using Immersive fullscreen but is doesn't seem to have any effect. Any suggestions?
You can hide the navigation bar using the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag.
Try this code
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
I want to disable status bar in my application.
link
with:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
I still can activate status bar with fast swipe from top to bottom screen.
Is possible to fully deactivate it?
What API version are you using? Anyway in the dedicated android developers page (Hiding the Status Bar) there is a detailed explanation on how to do it with additional clarification for API<16. In particular if the status bar should always remain hidden in your app you should set the activity theme in your app's manifest file as follows:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>