i have recycleview and in top i have one view which includes textview .
my problem is when scroll up that text-view always at top and only recycle-view scroll .. is any way i can scroll both . i don't want to use view type in recycle-view as it already use for some other purpose
my XML
<Rel layout>
<text-view id="text"/>
<recycle-view below="text" />
so how textview will go up and down with recycle-view scroll can any give small snippet for this
If you really want to keep the TextView separate from the RecyclerView, wrap them in a NestedScrollView
instead:
<NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView />
<RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
</NestedScrollView>
When you set up your RecyclerView, you will probably want to call RecyclerView#setNestedScrollingEnabled(false)
otherwise the RV may consume some scrolling inside the parent (which you don't want).
NOTE : This approach makes the tradeoff that the RV will be forced to layout all of its views, losing the recycling benefit. The correct approach would be to properly dedicate a viewType
to the RV for this header TextView and not deal with wrapping it inside additional ViewGroups.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.