我有一个ScrollView,包含垂直LinearLayout.的地方这是一个地方,我添加了一些名为"Section"的视图."Section" LinearLayout,包含一个TextView和`RecyclerView.
<ScrollView
android:id="@+id/main_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/sections_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
部分:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:textSize="@dimen/activity_starred_title_textsize" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
问题是有时RecyclerView并非真正的问题wrap_content.因此,它会产生两种类型的问题(取决于我尝试使用的解决方案类型).
它可以是不可滚动的(因此它匹配屏幕高度,我无法向下滚动以查看其中的其余项目).
它可以滚动嵌套.
最初的问题是它有嵌套滚动.所以我想要RecyclerViews简单的垂直LinearLayouts,唯一必须具有滚动效果的是rootScrollView.
我试过做什么?
扩展GridLayoutManager和覆盖canScrollVertically().方法:
public boolean canScrollVertically(){return false; }
扩展RecyclerView类和覆盖
@Override public boolean onInterceptTouchEvent(MotionEvent event){return false; }
@Override public boolean onTouchEvent(MotionEvent event){return false; } …