在单个滚动中滚动查看分页器和回收器视图

时间:2016-11-07 14:16:03

标签: android android-viewpager android-recyclerview android-tablayout

我正在开发的应用程序有4个带有查看寻呼机的选项卡。 tab1有滚动视图,在滚动视图中我有另一个带有视图寻呼机的标签布局...当我完全滑动tab1时,我希望子标签1中的回收视图也在它到达顶部时滚动..当前我需要单独滚动滚动视图和回收者视图..这是我的应用程序要求的图像... enter image description here

这是我的主要标签布局的xml:

<LinearLayout 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:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabMode="fixed"
            app:tabGravity="fill"/>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

这是Tab1的xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView 
    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">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <com.daimajia.slider.library.SliderLayout
                        android:id="@+id/homeBannerSlider"
                        android:layout_width="match_parent"
                        android:layout_height="150dp"
                        app:indicator_visibility="visible"
                        app:pager_animation="Default"
                        app:pager_animation_span="400">

                        <com.daimajia.slider.library.Indicators.PagerIndicator
                            android:id="@+id/custom_indicator"
                            style="@style/AndroidImageSlider_Corner_Oval_Orange"
                            android:layout_alignParentBottom="true"
                            android:layout_centerHorizontal="true"
                            android:background="#00000000" />
                    </com.daimajia.slider.library.SliderLayout>
                </RelativeLayout>

                <android.support.v7.widget.CardView
                    android:layout_width="match_parent"
                    android:layout_height="30dp"
                    android:elevation="0dp"
                    app:cardCornerRadius="0dp"
                    app:cardElevation="0dp">

                    <RelativeLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_alignParentLeft="true"
                            android:layout_centerVertical="true"
                            android:layout_marginLeft="20dp"
                            android:text="Latest Results" />
                    </RelativeLayout>
                </android.support.v7.widget.CardView>


          <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1"
                    android:orientation="vertical">
                    <android.support.design.widget.TabLayout
                        android:id="@+id/home_Sub_TabLayout"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        app:tabTextAppearance="@style/MineCustomTabText"
                        app:tabSelectedTextColor="@color/colorPrimary"
                        app:tabIndicatorColor="@color/colorPrimary"
                        app:tabTextColor="#858585"
                        app:tabMode="fixed"
                        app:tabGravity="fill"/>
                    <android.support.v4.view.ViewPager
                        android:id="@+id/home_Sub_Viewpager"
                        android:layout_width="match_parent"
                        android:layout_height="400dp">
                    </android.support.v4.view.ViewPager>
                </LinearLayout>
            </LinearLayout>
        </android.support.v4.widget.NestedScrollView>

带有回收站视图的subtab1的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
    android:id="@+id/trending_recycler_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>

</LinearLayout>

请建议我如何实现这一目标......

0 个答案:

没有答案
相关问题