Attach TextView to RecyclerView

10,218

Solution 1

I did the same using these two great resources:                                                        

https://plus.google.com/114432517923423045208/posts/EdkQFx1RqhE

https://gist.github.com/gabrielemariotti/4c189fb1124df4556058

                     

Solution 2

You can try Android-ObservableScrollView.

Refer following link: https://github.com/ksoichiro/Android-ObservableScrollView

Solution 3

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.

Share:
10,218
Martin Erlic
Author by

Martin Erlic

Personal Portfolio: http://www.martinerlic.com/ GitHub: https://github.com/seloslav LinkedIn: https://www.linkedin.com/in/martin-erlic/ Hey! My name is Martin. I am an experienced Software Engineer and Product Developer with a demonstrated history of working in the computer software industry. I am currently located in Victoria, BC. I love bringing products to life, from napkin sketch to working prototype and beyond. While I enjoy working in a collaborative team environment, I have extensive experience building and shipping my own products to the Google PlayStore and Apple App Store from the ground up. Want to build something great? Feel free to get in touch. I am interested in partnering with startups and small businesses to help them create lightning fast, strategic web and app solutions to help them grow. Skilled in Cloud Software, Databases, API Integrations, Web & Mobile Applications and UI Design. Web, Android and iOS applications HTML, CSS, JavaScript, Java, .NET, Kotlin, Swift ReactJS, React-Native, Blazor, MongoDB, CosmosDB, Entity Framework, Realm, Parse-Server Strong engineering and business development professional with a Bachelor of Arts - BA focused in Economics from University of Victoria.

Updated on July 24, 2022

Comments

  • Martin Erlic
    Martin Erlic almost 2 years

    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>
    
  • Martin Erlic
    Martin Erlic over 8 years
    I see... I really don't want to change from RecyclerView as I'm already deeply entrenched in it and it seems more performant for my purposes. I suppose I'll look into adding the TextView programatically.
  • Kyle Emmanuel
    Kyle Emmanuel over 8 years
    @bluemunch that would definitely be much efficient.
  • Kroltan
    Kroltan over 8 years
    Could you add an explanation of those links in the answer? If in the future any of them goes down, nobody will be able to benefit from this answer.