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.
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>
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>
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.