Reputation: 1260
I am new to Android Development. I want my app to support the screen size of my device i.e. 1080 x 2160 pixels
. Currently there is a black bottom bar that is displayed in place of where the navigation buttons would have been.
Please note that I do not want Full Screen Mode. I have disabled the button navigation on my device. It is only for this app that that the bottom black rectangle is showing.
I just want my app to support the gesture navigation system of my device instead of buttons.How do I make the bottom bar go away using Java (Android Studio
) so that my app utilizes that space?
Upvotes: 4
Views: 3811
Reputation: 71
I had the same issue, updated manifest file with this or remove if you have one.
before
<meta-data
android:name="android.max_aspect"
android:value="2.1" />
after
<meta-data
android:name="android.max_aspect"
android:value="2.4" />
working for me now.
Upvotes: 1
Reputation: 796
question is old but I faced the same issue and didnot find the solution on SO.
this problem occurs for long screens
We recommend that you design your app to support aspect ratios of 2.1 or higher. For this, you would add the following to the "application" element in your Manifest file:
<meta-data android:name="android.max_aspect" android:value="2.1" />
Upvotes: 3
Reputation:
Try to add this code
@Override
protected void onCreate(Bundle savedInstanceState) {
...
hideSystemUI(this, 1000);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// Hide bar after 1 second
hideSystemUI(this, 1000);
}
}
public static void hideSystemUI(@NonNull final Activity activity, final int delayMs) {
View decorView = activity.getWindow().getDecorView();
int uiState = View.SYSTEM_UI_FLAG_IMMERSIVE
| 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;
final Handler handler = new Handler();
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if (visibility == View.VISIBLE) {
Runnable runnable = new Runnable() {
@Override
public void run() {
hideSystemUI(activity, 1000);
}
};
handler.postDelayed(runnable, delayMs);
}
}
});
decorView.setSystemUiVisibility(uiState);
}
WARNING
If you have two activities, add this before changing
View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener(null);
Upvotes: 0
Reputation: 140
You can try this
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().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);
}
}
Upvotes: 0
Reputation: 742
Hi please Try below code
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
Upvotes: 0