- Home /
Hide Actionbar/NavigationBar
Hi averyone!
I spent a day to find what I do wrong, but I can't. I want to hide actionbar/navigationbar. I do the same things like all other, it helps to hide actionbar, but any taps on the screen brings it bar back over my screen =(
I suppose that may be I set this style for wrong View or maybe I sould listen some events.. I found that some persons recommend to listen Window.onWindowFocusChanged, but I don't know how to override it for Unity player window.
I tried to set style for UnityPlayer.currentActivity.getWindow().getDecorView() and had the same result.
And I found interesting moment, that taps in myUnityScripts are processed only when actionbar is visible... I belive that I set style for wrong view, but how to get corrent one?
Please help!
My java plugin I add below:
public static void Init(boolean fullscreen)
{
Log.d(TAG, "init (" + fullscreen + ")" );
if (UnityPlayer.currentActivity.getActionBar() != null)
{
Log.d(TAG, "getActionBar is not null");
UnityPlayer.currentActivity.getActionBar().hide();
} else {
Log.d(TAG, "getActionBar returns null =( ");
UnityPlayer.currentActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Log.d(TAG, "runOnUiThread -> run ()");
Window window = UnityPlayer.currentActivity.getWindow();
View targetView = window.getCurrentFocus();
targetView.setOnFocusChangeListener( new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
try
{
if (hasFocus) {
Log.d(TAG, "listener -> onFocusChange -> setting");
v.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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
);
}
} catch (Exception e) {
Log.d(TAG, "exception on setOnFocusChangeListener: " + e.toString());
}
}
});
targetView.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 // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
);
} catch (Exception e) {
Log.d(TAG, "Exception on setter " + e.toString());
}
}
});
}
Log.d(TAG, " < init");
}