【发布时间】:2019-11-27 10:30:12
【问题描述】:
我有一个带有 BottomSheet 的 CoordinatorLayout。如果 Bottomsheet 只有一个 RecyclerView,那么一切正常。我试图在 RecyclerView 顶部添加一些 Textview 和按钮,但是当 recyclerview 达到顶部高度时,它会在另一个视图下方滚动。我也希望其他视图也能滚动。 如果 BottomSheet 仅包含其他视图(没有 Recyclerview)也可以正常工作。 当我结合 RecyclerView 和其他视图元素(Button、TextView)时,滚动不如预期。
我想将 Recyclerview 上方的视图设置为列表的第一项,但这增加了适配器的复杂性。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="80dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text 2"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text 3"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:background="@android:color/white"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="true"/>
</LinearLayout>
【问题讨论】:
标签: android android-recyclerview android-coordinatorlayout bottom-sheet