Skip to content

Instantly share code, notes, and snippets.

@rnixx
Last active September 2, 2020 13:21
Show Gist options
  • Save rnixx/add38d808b5a8ad73947 to your computer and use it in GitHub Desktop.
Save rnixx/add38d808b5a8ad73947 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
)
@ghostersk
Copy link

Hi, I am trying to use this code, but I am failing. What Do i need to have installed and what Imports I need to add to buildozer.spec please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment