GoogleMapなどに用いられている画面が作成可能になりました。
実装はCoordinatorLayoutの子Viewに対して、Behaviorを指定するだけとシンプルです。
AOSPのソースコード : BottomSheetBehavior.java
Layoutのサンプル
BottomSheetはBehaviorを指定することで実装します。CoordinatorLayoutの子ViewとしてLayoutを追加して、BottomSheet化したいLayoutに対してapp:layout_behavior="@string/bottom_sheet_behavior"を指定します。
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
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 件のコメント:
コメントを投稿