Skip to content

Instantly share code, notes, and snippets.

@paulproteus
Created April 14, 2021 04:34
Show Gist options
  • Save paulproteus/a0d54da1fdf8687ec8b5d977db21f842 to your computer and use it in GitHub Desktop.
Save paulproteus/a0d54da1fdf8687ec8b5d977db21f842 to your computer and use it in GitHub Desktop.
diff
diff --git a/src/android/toga_android/window.py b/src/android/toga_android/window.py
index 5dd58700..6de00309 100644
--- a/src/android/toga_android/window.py
+++ b/src/android/toga_android/window.py
@@ -1,4 +1,5 @@
from . import dialogs
+from .widgets.base import _get_activity
class AndroidViewport:
@@ -15,7 +16,21 @@ class AndroidViewport:
@property
def height(self):
- return self.native.getContext().getResources().getDisplayMetrics().heightPixels
+ print(f"omg statusbar height {self._status_bar_height()}")
+ print(f"omg actionbar height {self._action_bar_height()}")
+ return self.native.getContext().getResources().getDisplayMetrics().heightPixels - self._status_bar_height() - self._action_bar_height()
+
+ def _action_bar_height(self):
+ # The app support action bar shows the app name & can provide menu options.
+ return _get_activity().getSupportActionBar().getHeight()
+
+ def _status_bar_height(self):
+ # The status bar is the platform widget that shows the time, etc.
+ resource_id = self.native.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android")
+ if resource_id > 0:
+ return self.native.getContext().getResources().getDimensionPixelSize(resource_id)
+ return 0
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment