I realize the following is incorrect but I suppose you can treat it as pseudocode. I'm wondering, how can I "attach" a whole layout to my RecyclerView so that when I scroll down the layout scrolls out of sight along with it. Presently the TextView above the RecyclerView is fixed on the screen, whereas all the data in my RecyclerView is scrollable. I want the TextView to move out of sight as the user scrolls down the page as well. If you look at Instagram, all the user profile information at the top of your gallery disappears as you scroll down the page. How can I do this? How can I add the TextView programatically?
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello!" />
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="?android:attr/actionBarSize"
android:padding="@dimen/item_margin"
android:id="@+id/recycler_view"
android:clipToPadding="false">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello!" />
</android.support.v7.widget.RecyclerView>
You can try Android-ObservableScrollView.
Refer following link: https://github.com/ksoichiro/Android-ObservableScrollView
I did the same using these two great resources:
https://plus.google.com/114432517923423045208/posts/EdkQFx1RqhE
https://gist.github.com/gabrielemariotti/4c189fb1124df4556058
You can add that TextView
as one of the RecyclerView
's items using a custom RecyclerAdapter
or you could use a ScrollView
with LinearLayout
as its content, instead of a RecyclerView
as it's not advisable to use one inside a ScrollView
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With