【问题标题】:Bottom Sheet holding a view above a Recyclerview - view starts scrolled out of view底部工作表在 Recyclerview 上方保存视图 - 视图开始滚动到视图之外
【发布时间】:2016-10-20 15:00:13
【问题描述】:

我在让底页正常工作时遇到问题

在底部工作表中,我在 RecyclerView(在本例中为 TextView)上方有一个项目 - 我希望滚动这两个项目,因此它们都包含在 NestedScrollView 中。

问题是,当屏幕加载时,TextView 被隐藏,我必须向下滚动 RecyclerView 以显示它,然后才能再次向上滚动整个视图以使底部工作表覆盖屏幕的其余部分。

我怎样才能使 TextView 已经在视图中?

```

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:behavior_hideable="false"
    app:behavior_peekHeight="auto"
    app:layout_behavior="@string/bottom_sheet_behavior">
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:background="@color/colorPrimaryDark"
                android:gravity="center"
                android:text="GYUHGHJG"/>
            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>
</FrameLayout>

``` 它是如何开始的 向下滚动后的外观(应该如何开始)

【问题讨论】:

    标签: android material-design bottom-sheet


    【解决方案1】:

    我尝试了一种解决方法,它成功了!!! 这不是一个有效的解决方案,但没有其他选择.. 在您的示例中,尝试使用相对布局而不是线性布局。并为 Recycler 视图提供顶部填充。

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:background="@color/colorPrimaryDark"
            android:gravity="center"
            android:text="GYUHGHJG"/>
        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingTop="25dp"/>
    </RelativeLayout>
    

    【讨论】:

    • 所以我想我在其他地方遇到了这个问题,解决方案是将顶视图(在 RecyclerView 之前)设置为focusableInTouchMode
    猜你喜欢
    • 1970-01-01
    • 2020-06-30
    • 1970-01-01
    • 1970-01-01
    • 2011-08-31
    • 2015-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多