首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何覆盖Scroll?

如何覆盖Scroll?
EN

Stack Overflow用户
提问于 2018-05-30 22:22:46
回答 1查看 158关注 0票数 0

我有以下布局:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/left_col"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="500dp"/>

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>

recyclerView的高度由代码预先定义,等于设备屏幕的高度。这个想法是,用户在屏幕上不会感觉到2个垂直滚动(也就是说,让他看起来像1个滚动)。如何使当textView1recyclerView开始前平滑滚动内容时,停止然后滚动通过recyclerView内部

EN

回答 1

Stack Overflow用户

发布于 2018-05-30 23:06:29

如果我没理解错的话,你有一些选择:

  1. 如果您不想滚动到RecyclerView之外,请将NestedScrollView更改为另一种ViewGroup,如LinearLayout.
  2. If您想要连续的垂直滚动,可以使用recyclerView.setNestedScrollingEnabled(false);

以编程方式禁用

此外,由于您使用的是静态高度android:layout_height="500dp",因此您的recyclerView将不具有动态屏幕大小

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50607132

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档