BottomSheets使用

参考:
Teach you how to use Design Support Library: Bottom Sheets
android developers blog
Android Support Library 23.2用法简析

注意:

如果要在Bottom Sheets里面使用滑动的布局,则需要使用nest scrolling。
Keep in mind that scrolling containers in your bottom sheet must support nested scrolling (for example, NestedScrollView, RecyclerView, or ListView/ScrollView on API 21+).
2. 必须要和CoordinatorLayout 连用

状态:

STATE_COLLAPSED: this collapsed state is the default and shows just a portion of the layout along the bottom. The height can be controlled with the app:behavior_peekHeight attribute (defaults to 0)。只显示一部分
STATE_DRAGGING: the intermediate state while the user is directly dragging the bottom sheet up or down。拖拽时
STATE_SETTLING: that brief time between when the View is released and settling into its final position。手松开滑动时。
STATE_EXPANDED: the fully expanded state of the bottom sheet, where either the whole bottom sheet is visible (if its height is less than the containing CoordinatorLayout) or the entire CoordinatorLayout is filled。全部展开时。
STATE_HIDDEN: disabled by default (and enabled with the app:behavior_hideable attribute), enabling this allows users to swipe down on the bottom sheet to completely hide the bottom sheet。根据该属性,全部隐藏。

属性:

app:layout_behavior=”@string/bottom_sheet_behavior” 这个属性是作为Bottom Sheet必须的属性
app:behavior_hideable=”false” 这个属性是当我们拖拽下拉的时候,bottom sheet是否能全部隐藏。
app:behavior_peekHeight=”0dp” 这个属性是当Bottom Sheets关闭的时候,底部下表我们能看到的高度。当app:behavior_hideable为false时会停留在该高度;为true时会根据速度来判断,可以完全消失。

测试了一下,BottomSheets好难用,而且资料太少。)

你可能感兴趣的:(BottomSheets使用)