4
我正在嘗試在我的佈局中實現持久性底部表單 - 一種不能完全隱藏但始終從底部偷看並可擴展至全高的表單。這是我的佈局:Android永久性底部表單初始可見性
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<!-- main content -->
</LinearLayout>
<LinearLayout
android:id="@+id/layoutBottomSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center|bottom"
android:background="@drawable/custom_background"
android:clipToPadding="false"
android:gravity="center_horizontal"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="50dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<!-- bottom sheet content -->
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
我希望發生是到底部片是可見的,只要我的土地在屏幕上崩潰,但它不是 - 這是隱藏的。我可以在onCreate()
中致電bottomSheetBehaviour.setState(BottomSheetBehavior.STATE_EXPANDED)
。奇怪的是,這只是稍微擴大了它 - 超過指定的偷看高度,但小於它應該佔據的整個高度。在它出現在這個狀態之後,我可以將它上下拖動到它應該在的位置,它工作正常。問題是在屏幕上的初始着陸是搞砸了。
我敢肯定有一種方法可以讓這個工作,所以底部表最初出現在它的偷看高度。有任何想法嗎?