我有底部工作表,我想改變它的行爲,所以它可以像在Google地圖應用程序的主屏幕上那樣工作,您可以將它展開到任何位置並將它放在那裏,並且它不會自動粘到底部或頂部。這裏是我的佈局下表:如何使底部表單(BottomSheetBehavior)可展開到任意位置?
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<View
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="16dp"
android:background="@drawable/shape_gradient_top_shadow"
app:layout_anchor="@+id/map_bottom_sheet" />
<LinearLayout
android:id="@+id/map_bottom_sheet"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fillViewport="false"
android:orientation="vertical"
app:behavior_peekHeight="50dp"
android:background="@color/lightGray"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior">
<include layout="@layout/bottom_sheet_top_buttons"/>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet_content_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightGray"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
我需要在本質上是消除迫使STATE_EXPANDED和STATE_COLLAPSED狀態的拖動結束時。
這裏是我做的嘗試,實現了可視化解釋:
正如你可以看到,底層不會自動錨定到頂部或底部,但在任何位置它留給停留。
嗨,你是否能夠實現這種行爲?我也很感興趣,謝謝! – dor506
@ dor506嗨,不,我正在努力實現這一目標,但我的團隊中的經理和設計人員隨時改變了需求,並決定他們需要標準的底部表單行爲:)但是,我發現爲了實現這一需求重新實現BottomSheetBehavior類;在我的情況下,我決定更改STATE_EXPANDED的邏輯,並在表單可見時分配此狀態,而不僅僅是當它粘到頂端時。或者你可以用其他方式重新思考。無論如何,我祝你好運,實施這一點。 –