Kotlin extensions for hiding/showing and observe keyboard state.
Add repository to your root build.gradle
repositories {
jcenter()
}
dependencies {
implementation 'com.idapgroup:keyboard-ktx:latest-version'
}
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
}
}
}