GoogleMapなどに用いられている画面が作成可能になりました。
実装はCoordinatorLayoutの子Viewに対して、Behaviorを指定するだけとシンプルです。
AOSPのソースコード : BottomSheetBehavior.java
Layoutのサンプル
BottomSheetはBehaviorを指定することで実装します。CoordinatorLayoutの子ViewとしてLayoutを追加して、BottomSheet化したいLayoutに対してapp:layout_behavior="@string/bottom_sheet_behavior"を指定します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | < android.support.design.widget.CoordinatorLayout android:layout_width = "match_parent" android:layout_height = "match_parent" tools:context = ".MainActivity" > < LinearLayout android:layout_width = "match_parent" android:layout_height = "match_parent" android:orientation = "vertical" app:layout_behavior = "@string/bottom_sheet_behavior" app:behavior_peekHeight = "240dp" app:behavior_hideable = "false" android:background = "@android:color/white" > < TextView android:layout_width = "match_parent" android:layout_height = "match_parent" android:text = "BottomSheet Sample" /> </ LinearLayout > </ android.support.design.widget.CoordinatorLayout > |
- app:behavior_peekHeight
- BottomSheetの最小表示サイズ
- app:behavior_hideable
- 下スクロールで完全に非表示にするかどうか。非表示後に上スクロールで表示可能
0 件のコメント:
コメントを投稿