Reputation: 3946
This is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/book_root_layout">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:id="@+id/book_spinner_root">
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/book_cat_show"
android:text="@string/show_categories"
android:layout_alignParentLeft="true"
android:layout_gravity="left"
android:ellipsize="end"
android:maxLines="1"
android:layout_marginLeft="5dp"
android:textSize="12sp"
android:stateListAnimator="@null"
android:background="@drawable/tagcat_button"
android:minHeight="0dp"
android:minWidth="0dp"
android:padding="7dp"
android:layout_centerInParent="true"
android:textColor="@color/white"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:visibility="visible"/>
<ProgressBar
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerInParent="true"
android:indeterminateTint="@color/colorAccent"
android:visibility="visible"
android:id="@+id/book_cat_prog"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:visibility="visible"
android:id="@+id/book_cat_spinner"
style="@android:style/Widget.Holo.Light.Spinner"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/book_tag_show"
android:text="@string/show_tags"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"
android:stateListAnimator="@null"
android:maxLines="1"
android:ellipsize="end"
android:textSize="12sp"
android:background="@drawable/tagcat_button"
android:minHeight="0dp"
android:minWidth="0dp"
android:padding="7dp"
android:layout_centerInParent="true"
android:textColor="@color/white"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:visibility="visible"/>
<ProgressBar
android:layout_width="30dp"
android:layout_height="30dp"
android:visibility="visible"
android:layout_centerInParent="true"
android:indeterminateTint="@color/colorAccent"
android:id="@+id/book_tag_prog"/>
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_margin="5dp"
android:id="@+id/book_tag_spinner"
style="@android:style/Widget.Holo.Light.Spinner"/>
</RelativeLayout>
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/book_spinner_root"
android:id="@+id/swipe_refrsh">
<android.support.v7.widget.RecyclerView
android:id="@+id/book_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:scrollbars="vertical"
android:scrollbarFadeDuration="500"/>
</android.support.v4.widget.SwipeRefreshLayout>
<include layout="@layout/loading"/>
</RelativeLayout>
What happens is that as I scroll the recyclerview, the LinearLayout (book_spinner_root) above the SwipeRefreshLayout
remains fixed to the top of the screen. But what I really wanted is the LinearLayout to scroll away as I am scrolling.
Please how do I achieve this?
Upvotes: 1
Views: 845
Reputation: 1122
You can use CoordinatorLayout
to achieve the scrolling effect you want (Make layout above RecyclerView
scoll away)
Upvotes: 0