Skip to content

Commit b1ba8dc

Browse files
committed
Introduce method get_keyboard_height that returns current softkeyboard
height if keyboard is active else 0.
1 parent c1cb694 commit b1ba8dc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

recipes/android/src/android/_android.pyx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ def get_dpi():
170170
cdef extern void android_show_keyboard(int)
171171
cdef extern void android_hide_keyboard()
172172

173+
# get keyboard height
174+
def get_keyboard_height():
175+
from jnius import autoclass
176+
python_act = autoclass('org.renpy.android.PythonActivity')
177+
rctx = autoclass('android.graphics.Rect')()
178+
mActivity = python_act.mActivity
179+
mActivity.getWindow().getDecorView().\
180+
getWindowVisibleDisplayFrame(rctx)
181+
height = mActivity.getWindowManager().getDefaultDisplay().getHeight()
182+
return height - rctx.bottom
183+
184+
173185
# Flags for input_type, for requesting a particular type of keyboard
174186
#android FLAGS
175187
TYPE_CLASS_DATETIME = 4

0 commit comments

Comments
 (0)