Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmsleight/9f7da2360f856f8ca45c392be7e652ab to your computer and use it in GitHub Desktop.
Save bmsleight/9f7da2360f856f8ca45c392be7e652ab to your computer and use it in GitHub Desktop.
Kivy App - Sticky hiding of navigation on Android
from kivy.app import App
from kivy.logger import Logger
try:
from jnius import autoclass
from android.runnable import run_on_ui_thread
android_api_version = autoclass('android.os.Build$VERSION')
AndroidView = autoclass('android.view.View')
AndroidPythonActivity = autoclass('org.renpy.android.PythonActivity')
Logger.debug(
'Application runs on Android, API level {0}'.format(
android_api_version.SDK_INT
)
)
except ImportError:
def run_on_ui_thread(func):
def wrapper(*args):
Logger.debug('{0} called on non android platform'.format(
func.__name__
))
return wrapper
class MyApp(App):
def on_start(self):
self.android_set_hide_menu()
def on_resume(self):
self.android_set_hide_menu()
@run_on_ui_thread
def android_set_hide_menu(self):
if android_api_version.SDK_INT >= 19:
Logger.debug('API >= 19. Set hide menu')
view = AndroidPythonActivity.mActivity.getWindow().getDecorView()
view.setSystemUiVisibility(
AndroidView.SYSTEM_UI_FLAG_LAYOUT_STABLE |
AndroidView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
AndroidView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
AndroidView.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
AndroidView.SYSTEM_UI_FLAG_FULLSCREEN |
AndroidView.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment