LoginSignup
4
4

More than 3 years have passed since last update.

指定したView で Snackbar を回避する

Posted at

やりたいこと

方法

回避したい View を CoordinatorLayout の内側に配置して app:layout_dodgeInsetEdges を指定する

<CoordinatorLayout>
  <!-- 回避したいView -->
  <View app:layout_dodgeInsetEdges="bottom" />
</CoordinatorLayout>

調べた

  • 24.2.0 のバージョンで CoordinatorLayout.Behavior を継承してカスタムする方法から app:layout_dodgeInsetEdges を設定する方法に変わったようです。

  • 下から以外の他の方向からの Inset に対応したい場合は all を設定する方法があります。

https://twitter.com/yuichi_araki/status/766129341382078468


  • つまり、 Snackbar には app:layout_insetEdge の属性が付与されているということみたいです。

この機能が実装されてから随分経つはずですが、知りませんでした。

参考になった記事 :bow:

4
4
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
4
4