【发布时间】:2018-08-07 10:14:08
【问题描述】:
假设我的底部工作表有如下几行小部件。如果我最初只想显示前两行(即前两行LinearLayouts),而不是下面的其余小部件。我不希望最初看到那些。如何设置正确的窥视高度?硬编码app:behavior_peekHeight 可能不起作用,所以我需要以编程方式设置它,但是如何计算高度?
或者有没有更推荐的方法来获得相同的结果?我的意思是,如果我测试谷歌地图,长按一个位置首先只显示标题部分作为底部表,但是当我尝试向上滚动底部表时,感觉好像标题部分(这可能不是真实的bottom sheet) 被替换为包含所有元素的真实底部表。如果我的解释还不够,请自行尝试谷歌地图。
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView/>
<android.support.v7.widget.AppCompatSpinner/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView/>
<TextView/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView/>
<TextView/>
</LinearLayout>
<android.support.v7.widget.RecyclerView/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
【问题讨论】:
标签: android android-layout android-widget bottom-sheet