Reputation: 441
I use the following code to enter Immersive sticky mode in Android.
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
What I want is: I want the status bar and navigation bar to show when I touch the center part of my Activity instead of swiping from the edge. Is that possible?
Upvotes: 0
Views: 4293
Reputation: 106
If you don't want to write any additional code (just call some methods) then use SystemUIHelper from here: https://gist.github.com/chrisbanes/73de18faffca571f7292
and then something like this:
...
SystemUiHelper uiHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.[Your content view]);
uiHelper = new SystemUiHelper(this, [Your flags/modes]);
// Then set onTouchListener on youк root view
// and when someone touch it you will receive an event about it
// and will be able to manage it and hide/show app's UI again
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()){
case MotionEvent.ACTION_UP:
if (uiHelper.isShowing()){
uiHelper.hide();
}else{
uiHelper.show();
}
break;
}
return super.onTouchEvent(event);
}
Upvotes: 1