0

I have this activity design, which shows a card view inside a scrollView, But under that cardview I need to put a listview or recyclerview. The problem is that I need the scroll of that list to coordinate with the main scroll. Osea that when lower in the content the cardview will disappear and the list of the recyclerview or listview will be crossed.

I need all the content to respond to the main scroll to show up and disappear after titlebar, Which should I change or redesign?

Captura de Imagen

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


    <android.support.v7.widget.CardView
        app:cardElevation="5dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.design.widget.CoordinatorLayout
            android:id="@+id/post_coordinator"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <ImageView
                android:id="@+id/post_bg"
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:scaleType="fitXY"
                android:src="@drawable/default_profile" />

            <android.support.design.widget.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:fabSize="normal"
                android:src="@drawable/ic_hot_black"
                app:layout_anchorGravity="bottom"
                android:layout_marginLeft="16dp"
                app:layout_anchor="@id/post_bg"
                android:tint="#FFF"
                />

            <com.mikhaellopez.circularimageview.CircularImageView
                android:layout_width="100dp"
                android:layout_height="100dp"
                app:layout_anchor="@id/post_bg"
                app:layout_anchorGravity="center_horizontal|bottom"
                android:src="@drawable/profile"
                app:civ_border_color="#FFF"
                app:civ_border_width="3dp"
                />


            <android.support.design.widget.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:fabSize="normal"
                android:src="@drawable/ic_hot_black"
                app:layout_anchorGravity="bottom|end"
                android:layout_marginRight="16dp"
                app:layout_anchor="@id/post_bg"
                android:tint="#FFF"
                />


            <LinearLayout
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_marginTop="205dp"
                android:paddingLeft="20dp"
                android:paddingRight="20dp"
                android:paddingBottom="50dp"
                android:layout_height="wrap_content">


                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Prepare your Anus Cersei Lanister, You Gonna Die"
                    android:textAppearance="@style/Base.TextAppearance.AppCompat.Large"
                    android:textColor="#2d2d2d"
                    android:textAlignment="center"
                    />


                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAlignment="center"
                    android:text="@string/emilia"
                    android:textColor="@color/secondary_text"
                    android:layout_marginTop="10dp"
                    />

            </LinearLayout>

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

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


    <ListView
        android:id="@+id/post_comments"
        android:layout_marginTop="16dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
    </ListView>

    </LinearLayout>
</ScrollView>
  • 1
    You shouldn't put one scroll view within another. i.e: `ListView` within `ScrollView`. If you have to then use `NestedScrollView` and `RecyclerView`. – Sharjeel Jul 08 '17 at 01:32

3 Answers3

2

Add your recyclerview inside NestedScrollview. Also add recyclerview.setNestedScrollingEnabled(false);

Yyy
  • 2,285
  • 16
  • 29
0

Use android:fillViewport="true" to your ScrollView. ListView that located inside ScrollView works properly.

<ScrollView
android:id="@+id/scrollView" 
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
Payal
  • 31
  • 4
0

I'd recommend putting the CardView inside the RecyclerView as a header, and then you don't need the top ScrollView, the card and the list items would all be scrollable within the RecyclerView.

There are many ways to add a header to a RecyclerView, see here: Is there an addHeaderView equivalent for RecyclerView?

marmor
  • 27,641
  • 11
  • 107
  • 150