Linear layout - RecyclerView scrolls only
I'm trying to scroll the entire page, but only RecyclerView
scrolling in that light blue area? What can I do? here is my xml. When I try to scroll, it only scrolls RecyclerView
in its area.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
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"
android:background="@color/background_color">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/tab_user_image"
android:scaleType="centerCrop"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="11pt"
android:textStyle="bold"
android:textColor="@color/tabsScrollColor"
android:layout_marginTop="160dp"
android:layout_marginLeft="24dp"
android:id="@+id/tab_user_name"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="6dp"
android:paddingBottom="10dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:layout_marginTop="10dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/tabsScrollColor"
android:layout_weight="0.25"
android:textSize="8pt"
android:layout_gravity="center_vertical"
android:id="@+id/tab_user_follower"
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal"
android:id="@+id/tab_user_following"
android:textColor="@color/tabsScrollColor"
android:textSize="8pt"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25"
android:layout_gravity="center_vertical"
android:gravity="right"
android:textColor="@color/tabsScrollColor"
android:id="@+id/tab_user_point"
android:textSize="8pt"
android:paddingRight="8dp"/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/star_smooth"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tab_user_recycler_view"
/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fabSize="normal"
android:id="@+id/tab_user_fab"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:transitionName="@string/fab_transition_name"
android:src="@drawable/fab_image"
app:layout_anchor="@id/tab_user_recycler_view"
app:layout_anchorGravity="bottom|right|end"
app:backgroundTint="@color/app_color"
/>
</LinearLayout>
Here is an image of what it looks like:
source to share
Scrolling must be enabled by packaging your LinearLayout
in ScrollView
.
But if you do, your scroll may break, as you have RecyclerView
in ScrollView
.
The simplest is your main image and text, which needs to be wrapped in a separate cell (renderer) and then add it just like any other cell in your recycler view.
source to share