Skip to content

Conversation

@bu-tokumitsu
Copy link

@bu-tokumitsu bu-tokumitsu commented Sep 16, 2025

概要

Android 15からのEdge-to-Edgeのサポート追加

  • 対応内容
    • ViewCompat.setOnApplyWindowInsetsListenerの実装
      • 内部でinsetを取得
      • Edge-to-Edge表示に干渉するviewにinsetを設定する
    • ActionBarを使用している場合、inset情報に含まれない
      • themeをNoActionBarに変更しlayout xmlで別途toolbarを配置

関連Issues

動作検証

  • 前提
    • APIレベルを35にしてEdge-to-Edgeを有効にして検証しています
  • 検証機種:Pixel 9 Pro - Android OS 15
変更前 変更後

@bu-tokumitsu
Copy link
Author

@laiso @yatatsu cc: @koutaku921
Edge-to-Edgeの対応を加えてみましたのでレビューお願いいたします。

right = insets.right,
bottom = insets.bottom,
)
WindowInsetsCompat.CONSUMED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ScrollView の下端がソフトウェアキーボードに隠れてしまうため、WindowInsetsCompat.Type.ime()でPaddingを調整する必要がありました。

例:

internal fun View.applyWindowInsets() {
    val initialLeft = paddingLeft
    val initialTop = paddingTop
    val initialRight = paddingRight
    val initialBottom = paddingBottom

    ViewCompat.setOnApplyWindowInsetsListener(this) { v, windowInsets ->
        val systemInsets = windowInsets.getInsets(
            WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
        )
        val imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime())
        val bottomInset = maxOf(systemInsets.bottom, imeInsets.bottom)

        v.updatePadding(
            left = initialLeft + systemInsets.left,
            top = initialTop + systemInsets.top,
            right = initialRight + systemInsets.right,
            bottom = initialBottom + bottomInset,
        )
        windowInsets
    }
    ViewCompat.requestApplyInsets(this)
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laiso
ありがとうございます!
64209fbでキーボードのinsets追加の修正加えています。

修正後の動画も添付します。
ご確認お願いします🙏

Screen_recording_20250920_151321.mp4
Screen_recording_20250920_151250.mp4

@bu-tokumitsu bu-tokumitsu requested a review from laiso September 20, 2025 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants