Help us understand the problem. What is going on with this article?

AndroidのWebViewでキーボードが入力欄にかぶってしまうとき

(日本語資料が少なくて、探すのにけっこう苦労したのでメモ)
AndroidでWebViewをそのまま使うと、入力欄を押してソフトキーボードが出現させたときに、キーボードが画面にかぶってしまうことがある。

そんなときは、対象WebViewを含むFragment or ActivityのonCreate()に以下のコードを入れれば良い。

fragment.kt
override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        activity?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
    }

これで、キーボードが出現したときにもFragment or Activityの大きさが再計算されて、キーボードが被らなくなる。

出典
Window Soft Input Mode ConstraintLayout

hiraike32
フロントエンドエンジニア(React/TypeScript/Android)。SPAやCSSアニメーション、Androidアプリを作って生きたい。
dwango
Born in the net, Connected by the net.
https://dwango.co.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした