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?

【Android】EdgeToEdgeの対応のチートシート

Last updated at Posted at 2025-05-18

はじめに

Android SDK35以降から必要となる対応で対応内容などを調べなおしたりするのが面倒だと思ったので簡単なものをメモがわりに記事に残しておきます。

実装

ViewExtensionsなどで用意して各画面に書く。
もしくは、BaseActivityなどが広い画面に継承されている親クラスがあるならそこで実装するといい。

  ViewCompat.setOnApplyWindowInsetsListener(this) { v, windowInsets ->

    // インセットをビューのマージンとして適用します。
    // paddingでも可
    v.updateLayoutParams<MarginLayoutParams> {
      topMargin = insets.top
      bottomMargin = insets.bottom
      leftMargin = insets.left
      rightMargin = insets.right
    }

   // ウィンドウのインセットを子孫ビューに渡し続けたくない場合は、CONSUMED を返します。
    WindowInsetsCompat.CONSUMED
  }

参考

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?