android full screen an activity and hide key bar
Asked Answered
J

2

6

i am new in android programming! i want a full screen image like Hill Climb Racing (as you can see below)

Hill Climb Racing

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)

Jeffiejeffrey answered 25/3, 2014 at 17:26 Comment(0)
H
9

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

Homework answered 25/3, 2014 at 17:41 Comment(5)
but how can i keep this? and hide it again? i override onTouch event but key bar still appeare. :(Jeffiejeffrey
from the points given in the developer site... i think this is not possible. Did u check this link developer.android.com/training/system-ui/visibility.htmlHomework
yep! i find the answer, we should put that in onResume no onTouch !! thanks again for your help!Jeffiejeffrey
i dont know whether this will help ur query since hiding bar would stop your navigation. Lets see if someone comes up with a better solutionHomework
while mentioned targeting android 4.0 why it appear warning for View.SYSTEM_UI_FLAG_FULLSCREEN ?Nittygritty
C
3

try this in your activity on the manifest

 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
Caesarea answered 25/3, 2014 at 17:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.