0

I have a xml Layout that consist of two sections ; in top of layout there is a ViewPager and below it there is a RecyclerView.(left picture).

I want when recycler view scrolling up ViewPager move and fadeOut.

enter image description here

My XML layout code is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<android.support.v4.view.ViewPager
    android:id="@+id/slider"
    android:layout_width="match_parent"
    android:layout_height="200dp" />

<android.support.v7.widget.RecyclerView
    android:id="@+id/lstLatestNews"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/slider" /></LinearLayout>

2 Answers2

0

you can use CoordinatorLayout + AppBarLayout + CollapsingToolbarLayout

 <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar_group_purchase"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <!--广告栏-->
            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_scrollFlags="scroll">

                <com.youth.banner.Banner
                    android:id="@+id/banner_home_group_purchase"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/banner_height" />
            </android.support.design.widget.CollapsingToolbarLayout>
            <!--类别Tab-->
            <include layout="@layout/layout_tab_more" />
        </android.support.design.widget.AppBarLayout>

        <!--分类视图-->
        <android.support.v4.view.ViewPager
            android:id="@+id/vp_home_group_purchase"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/white"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    </android.support.design.widget.CoordinatorLayout>
FunyFate
  • 3
  • 3
-2

You just your layout inside scroll view

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="10dp"
android:scrollbars="none">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v4.view.ViewPager
android:id="@+id/slider"
android:layout_width="match_parent"
android:layout_height="200dp" />

<android.support.v7.widget.RecyclerView
android:id="@+id/lstLatestNews"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/slider" />
</LinearLayout>

</ScrollView>
udayatom
  • 126
  • 1
  • 7
  • thanks for your response, I done it but Recycler View disappeared and gone! –  Nov 02 '16 at 06:20