如何在Android中滚动查看寻呼机+回收站视图

时间:2016-11-01 17:15:29

标签: android layout android-viewpager android-recyclerview nestedscrollview

我有一个xml布局,包含两个部分; 在布局顶部有一个ViewPager,在它下面有一个RecyclerView。(左图)。

我希望当回收者视图向上滚动ViewPager move和fadeOut。

enter image description here

我的XML布局代码是:

<?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 个答案:

答案 0 :(得分:0)

你可以使用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>

答案 1 :(得分:-1)

您只是滚动视图中的布局

<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>
相关问题