Skip to content

Kotlin extensions for hiding/showing and observe keyboard state.

License

Notifications You must be signed in to change notification settings

idapgroup/keyboard-ktx

Repository files navigation

Keyboard Kotlin Extensions

Kotlin extensions for hiding/showing and observe keyboard state.

Download

Download

Add repository to your root build.gradle

repositories {
    jcenter()
}
dependencies {
  implementation 'com.idapgroup:keyboard-ktx:latest-version'
}

Usage sample

class ExampleActivity  :  AppCompatActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        changeKeyboardStateButton.setOnClickListener {
            if(isKeyboardShown) {
                hideKeyboard() 
            } else {
                editText.showKeyboard()
            }
        }
        onKeyboardShowChanged { shown: Boolean, height: Int ->
            // your use of shown and height
        }
    }
}