0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Androidでキーボードの表示非表示を検知する【Kotlin】

0
Posted at

準備

こちらのライブラリを使ってソフトキーボードの表示中を検知します。
↑を元に準備していきます。

build.gradle(:app)
dependencies {
    api 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'
}

実践

MainActivity.kt
     KeyboardVisibilityEvent.setEventListener(this) {
            KeyboardVisibilityEventListener {
                   if (it) {
                    // 表示
                } else {
                    // 非表示
                }
            }
        }

KeyboardVisibilityEvent.setEventListener()の引数にActivityを追加

KeyboardVisibilityEventListener {

}

内で表示非表示の判定ができる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?