【发布时间】:2017-03-27 06:41:50
【问题描述】:
我在屏幕上滚动时遇到了一点问题。布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/my_account_parent_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!--- Views omitted --->
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.RecyclerView
android:id="@+id/my_account_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
问题是 recyclerview 不能在 Scrollview/NestedScrollView 中,这就是它在滚动视图之外的原因。现在我需要包装在 LinearLayout 中的视图,当用户在任何视图(RecyclerView 和它上面的所有其他视图)上滚动时,它被包裹在 NestedScrollView 上以向上滚动。即使其他视图有一个滚动视图包裹在他们周围,他们没有意识到他们可以滚动屏幕,即使 recyclerview 有屏幕之外的内容?
谢谢
【问题讨论】:
-
你能发布包含布局的完整 xml 文件吗??
-
@SurajMakhija 完成
-
好的,很好
标签: java android android-recyclerview android-xml android-nestedscrollview