Android-滚动视图内的Recycleview [英] Android - Recycleview Inside Scrollview
问题描述
我正在构建一个社交应用程序,并且具有查看用户个人资料的活动(例如Instagram).
I am building a social app and have an activity for viewing user's profiles (like Instagram).
我基本上希望能够正常自然地从ScrollView滚动到RecyclerView,反之亦然. 因此,例如,如果用户从RecyclerView的底部进行了强烈的滑动,我希望它可以将他带到ScrollView的顶部.我在考虑以下解决方案(但实际上并不知道该怎么做):使RecyclerView的高度扩大",使其包含所有项目,但没有滚动条,因此ScrollView可以做到这一点是很自然的事情.
I basically want to be able to scroll normally and naturally from the ScrollView to the RecyclerView and viceversa. So for example, if the user does a strong swipe from the bottom of the RecyclerView I want it to take him up to the top of the ScrollView . I was thinking of the following solution (but don't really know how to do it): make the RecyclerView's height "expanded" so it would contain all the items but with no scrollbar, so that the ScrollView can do it's a natural thing.
我的布局如下:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- FIRST REGION THIS IS SET PRGRAMATICALLY TO TAKE UP WHOLE SCREEN-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView> <Textview> <Bla> <Bla>
</RelativeLayout>
<!-- SECOND REGION ALSO SET TO TAKE UP ALL SCREEN PROGRAMATICALLY-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
/>
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</RelativeLayout>
推荐答案
使用此mRecyclerView.setNestedScrollingEnabled(false);
这篇关于Android-滚动视图内的Recycleview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!