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 SystemBarの高さを取得する(最新版)

Posted at

はじめに

以前書いた、こちらの記事ではやり方が古く、非推奨だったので新しやり方を記事にしておきます。

実践

ViewCompat.setOnApplyWindowInsetsListener(R.id.content) { v, windowInsets ->
  val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
  insets.top // statusBar
  insets.bottom // navigationBar
  
  WindowInsetsCompat.CONSUMED
}
   windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())

の引数にはsystemBars()以外にもstatusBarBars()やnavigationBars()などを指定できるため
適宜使用用途に合わせて使っていきたい。

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?