All Projects → Crysis21 → Keyboardheightprovider

Crysis21 / Keyboardheightprovider

Get android keyboard height using an overlay popup-window

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Keyboardheightprovider

Armory Keyboard
utility for emulating a USB HID keyboard with the USBArmory
Stars: ✭ 28 (-44%)
Mutual labels:  keyboard
Jquery Keyfilter
This plugin filters keyboard input by specified regular expression.
Stars: ✭ 37 (-26%)
Mutual labels:  keyboard
Pxt Bluetooth Keyboard
BLE HID Keyboard module for micro:bit
Stars: ✭ 44 (-12%)
Mutual labels:  keyboard
Silence
A simple, clean macro recorder written in C#. Windows 10 compatible.
Stars: ✭ 29 (-42%)
Mutual labels:  keyboard
Cmd Toutiao
摸鱼神器:在命令行中看今日头条
Stars: ✭ 34 (-32%)
Mutual labels:  keyboard
Kfreestyle2d
Unofficial Kinesis Freestyle 2 Userspace Linux Driver
Stars: ✭ 41 (-18%)
Mutual labels:  keyboard
Sodieremojikeyboardplus
支持自定义emoji表情,icon font , FontAwesome,斜体,超链接,粗体,下划线,字体,颜色,镂空字体等富文本
Stars: ✭ 14 (-72%)
Mutual labels:  keyboard
Commonkeyboard
An elegant Keyboard library for iOS. simple, lightweight and standalone no sub-dependencies required
Stars: ✭ 47 (-6%)
Mutual labels:  keyboard
Chrome Virtual Keyboard
Touch-friendly Virtual Keyboard for Chrome browser
Stars: ✭ 35 (-30%)
Mutual labels:  keyboard
Tertiary text
[Pebble] Tertiary text input for the Pebble!
Stars: ✭ 43 (-14%)
Mutual labels:  keyboard
Mechanical Keyboard
DIY mechanical keyboard and where to find them
Stars: ✭ 947 (+1794%)
Mutual labels:  keyboard
Emojikeyboard
自定义表情键盘(支持系统表情, 图片表情),仅供参考学习~
Stars: ✭ 33 (-34%)
Mutual labels:  keyboard
Typist
Swift UIKit keyboard manager for iOS apps.
Stars: ✭ 1,011 (+1922%)
Mutual labels:  keyboard
Voyager65 Keyplus
65% keyboard PCB for Keyplus firmware. Simplified variants available.
Stars: ✭ 29 (-42%)
Mutual labels:  keyboard
Skr
Low level key re-programming
Stars: ✭ 47 (-6%)
Mutual labels:  keyboard
Keystroke dynamics
a keystroke dynamics algorithm in python (recognizes a person by the way s/he types)
Stars: ✭ 21 (-58%)
Mutual labels:  keyboard
React Spreadsheet Grid
An Excel-like grid component for React with custom cell editors, performant scroll & resizable columns
Stars: ✭ 996 (+1892%)
Mutual labels:  keyboard
Atreis
Stars: ✭ 48 (-4%)
Mutual labels:  keyboard
Gingham pcb
A 60% throughole keyboard inspired by the Plaid
Stars: ✭ 45 (-10%)
Mutual labels:  keyboard
Inputsystem
An efficient and versatile input system for Unity.
Stars: ✭ 1,013 (+1926%)
Mutual labels:  keyboard

Keyboard Height Provider

Getting keyboard height in android it's a pain in the ass. For activities where soft input mode is adjustResize, you can set up an OnGlobalLayoutListener and measure how the activity window is resized, to make room for the keyboard.

For other modes of soft input mode, you're out of luck. As the android brick-heads refuse to solve this problem even after 28 iterations of SDK development, someone came with a cool solution:

  • create a pop-up window and observe it's global layout changes
  • set it's soft input behaviour as adjustResize
  • attach this popup window to your activity and let it report the keyboard height, based on it's layout changes.

Set up

Add the following repo to your project

    repositories {
        maven {
            url  "https://dl.bintray.com/crysis21/Android"
        }
    }

Add the following dependency to your project:

    implementation 'com.hold1:keyboardheightprovider:0.0.9'

Usage

  1. Keep a reference to KeyboardHeightProvider in your activity.

        private var keyboardHeightProvider: KeyboardHeightProvider? = null
    
  2. Create a KeyboardListener

        private fun getKeyboardListener() = object : KeyboardHeightProvider.KeyboardListener {
            override fun onHeightChanged(height: Int) {
                sizeText.text = "$height"
            }
        }
    
  3. Create the height provider after your activity has been created and register the listener.

        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContentView(R.layout.activity_main)
            keyboardHeightProvider = KeyboardHeightProvider(this)
            keyboardHeightProvider?.addKeyboardListener(getKeyboardListener())
        }
    
  4. Override activity lifecycle and make sure you notify the KeyboardHeightProvider

        override fun onResume() {
            super.onResume()
            keyboardHeightProvider?.onResume()
        }
    
        override fun onPause() {
            super.onPause()
            keyboardHeightProvider?.onPause()
        }
    

Also the KeyboardInfo object provides information about the current state of the keyboard, and it's cached height.

Credits

All credits for this project goes to Siebe Brouwer. He had a great idea of using an android PopupWindow in order to extract the keyboard height in activities where you don't want to use the adjustResize behaviour.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].