SlidingPaneLayout
日付:2021/09/09
URL:https://developer.android.com/guide/topics/ui/layout/twopane?hl=ja
調査者:mayamito
カテゴリ:Jetpack, Library
一言で表すと
マルチペインのレイアウトを簡単に作成できるやつ
概要
https://developer.android.com/images/ui/slidingpanelayout-example.png?hl=ja
↑こういうレイアウトを実装するためのView
使い方
code:two_pane.xml
<!-- two_pane.xml -->
<androidx.slidingpanelayout.widget.SlidingPaneLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sliding_pane_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The first child view becomes the left pane. When the combined
desired width (expressed using android:layout_width) would
not fit on-screen at once, the right pane is permitted to
overlap the left. -->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_pane"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_gravity="start"/>
<!-- The second child becomes the right (content) pane. In this
example, android:layout_weight is used to expand this detail pane
to consume leftover available space when the
the entire window is wide enough to fit both the left and right pane.-->
<androidx.fragment.app.FragmentContainerView
android:id="@+id/detail_container"
android:layout_width="300dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#ff333333"
android:name="com.example.SelectAnItemFragment" />
</androidx.slidingpanelayout.widget.SlidingPaneLayout>
1つめの子が左のpaneに、2つめの子が右のpaneになる。
このように、子Viewを水平に並べて表示する。
子のペインを並べて表示できるだけの幅がある場合、そのまま並べて表示する。
子のペインを並べて表示できるだけのViewの幅がない場合、子は折りたたまれて表示される。ユーザーは表示させたい子をスライドさせて表示する。
SlidingPaneLayoutの使いみちとして、連絡先リストと連絡先の詳細のような、ペイン間に直接的な情報階層がある場合などに使用されるのが望ましい。ペイン間に直接的なつながりのない場合、例えばNavigationとして使うなどは不適切。
chigichan24.icon foldable phoneとかとも相性良さそう
Mori Atsushi.icon 折り目に合わせるとかできるのかな
気になるポイント
子はいくつまで入れられるんだろう
BottomNavigationは確か5つ以上入れると例外を吐いた気がするので
Jetpack Composeで使いたい(すぐCompose使いたがるおじさん)
このくらいならAndroidViewで簡単にラッパー作れそうな気もする
Mori Atsushi.icon フルComposeで書いて
コメント
Go.icon横画面の時に使うことはありそう