0
  • Using nested scrollview inside recyclerview is a bad idea.becuase It will load all 200 gridview when coming to this activity.so i removed nested scroll view.

  • For nested scroll view replacement I need to use the app:layout_scrollFlags="scroll" posted in this SO Post.

  • My layout looks like this instagram profile page.

Below I have posted the layout code:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/White"
            app:theme="@style/ThemeOverlay.AppCompat">

            <RelativeLayout
                android:id="@+id/rl_profile_top_layout"
                android:layout_width="match_parent"
                android:layout_height="55dp"
                android:background="@color/White"
                android:paddingTop="5dp">

                <TextView
                    android:id="@+id/tv_profile_title"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:text="@string/user_name"
                    android:textColor="@color/Black"
                    android:textSize="@dimen/txt_size_large"
                    android:textStyle="bold" />

                <ImageView
                    android:id="@+id/iv_settings_back_tab_profile"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:layout_alignParentEnd="true"
                    android:layout_alignParentRight="true"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:contentDescription="@string/cont_desc"
                    android:paddingRight="5dp"
                    android:src="@drawable/setting_icon" />



            </RelativeLayout>

        </android.support.v7.widget.Toolbar>



        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true">


            <RelativeLayout
                android:id="@+id/relative_top_scroll"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll">



            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <RelativeLayout
                    android:id="@+id/rl_profile_main_datas"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingTop="5dp">

                    <com.golive.entertainment.thirdparty.RoundedImageView
                        android:id="@+id/iv_user_profile_tab_more"
                        android:layout_width="70dp"
                        android:layout_height="70dp"
                        android:layout_margin="20dp"
                        android:layout_marginTop="20dp"
                        android:scaleType="fitXY"
                        android:src="@drawable/profile_pic_circle" />



                 ...................(more than 10 views)
                 ..................



              </RelativeLayout>

             ...................
             ...................

            </LinearLayout>


            </RelativeLayout>



                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rv_grid_view_tab"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_margin="10dp"
                    android:scrollbars="none"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior"
                    android:visibility="visible">

                </android.support.v7.widget.RecyclerView>


                <android.support.v7.widget.RecyclerView
                    android:id="@+id/rv_list_tab_more_profile"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="10dp"
                    android:clipToPadding="false"
                    android:scrollbars="none"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior"
                    android:visibility="gone" />

                <TextView
                    android:id="@+id/profile_user_no_post_tv_tab"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginTop="60dp"
                    android:visibility="gone"
                    android:text="@string/txt_no_posts_available"
                    android:textSize="@dimen/txt_size" />


        </android.support.design.widget.AppBarLayout>

    </LinearLayout>
</android.support.design.widget.CoordinatorLayout>
  • My issue is, If I scroll the recyclerview, it is scrolling the recyclerview only.

  • My need is, it have to scroll the relativelayout (relative_top_scroll) also, when scrolling the recyclerview.

Note: I tried multiple row layout only for top relativlayout.but it is not possible here.because when clicking the grid button it will load gridview recyclerview.On clicking the list button it will show the listview recyclerview.Same thing like instagram.

Community
  • 1
  • 1
Stephen
  • 9,899
  • 16
  • 90
  • 137

1 Answers1

0

you just add the scrollview below the toolbar instead of relative layout, and put all the code inside of this scrollview

Sam
  • 45
  • 1
  • 8