Fragment NestedScrollview不滚动

时间:2016-12-08 10:22:10

标签: android android-fragments android-recyclerview android-nestedscrollview

我在我的代码中使用了NestedScrollView,如下面的xml文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
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:background="@android:color/white"
android:orientation="vertical">
<RelativeLayout
    android:id="@+id/RR1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="-3dp"
        android:background="@drawable/action_main">
        <de.hdodenhof.circleimageview.CircleImageView 
            android:id="@+id/imageView4"
            android:layout_width="35dp"
            android:layout_height="35dp"
            android:layout_gravity="right|center_vertical"
            android:layout_marginRight="15dp"
            android:src="@drawable/test_profile"
            app:civ_border_color="#FFFFFF"
            app:civ_border_width="2dp" />
    </FrameLayout>
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/RR1"
    android:fillViewport="true"
    android:scrollbarAlwaysDrawVerticalTrack="true">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <RelativeLayout
            android:id="@+id/RR2"
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:background="@android:color/white"
            android:padding="7dp">
            <ImageView
                android:id="@+id/imageView5"
                android:layout_width="20dp"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:src="@drawable/search" />
            <EditText
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginLeft="10dp"
                android:layout_toRightOf="@+id/imageView5"
                android:background="@null"
                android:hint="Search for influencers and categories"
                android:textColor="@android:color/black"
                android:textColorHint="@android:color/darker_gray"
                android:textSize="14dp" />
        </RelativeLayout>
        <View
            android:id="@+id/View1"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:layout_below="@+id/RR2"
            android:background="@color/color_grey" />
        <LinearLayout
            android:id="@+id/LL1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/View1"
            android:layout_margin="5dp"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="CATEGORIES"
                android:textColor="@android:color/black"
                android:textStyle="bold" />
            <android.support.v7.widget.RecyclerView
                android:id="@+id/my_recycler_view_up"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="none" />
        </LinearLayout>
        <View
            android:id="@+id/View2"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:layout_below="@+id/LL1"
            android:background="@color/color_grey" />
        <LinearLayout
            android:id="@+id/LL2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/View2"
            android:layout_margin="5dp"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="FEATURED INFLUENCERS"
                android:textColor="@android:color/black"
                android:textStyle="bold" />
            <android.support.v7.widget.RecyclerView
                android:id="@+id/my_recycler_view_featured"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbars="none" />
        </LinearLayout>
        <View
            android:id="@+id/Viewbelowfeature"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:layout_below="@+id/LL2"
            android:background="@color/color_grey" />
        <android.support.design.widget.CoordinatorLayout 
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/Viewbelowfeature">
            <android.support.design.widget.AppBarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                >
                <android.support.design.widget.TabLayout
                    android:id="@+id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@android:color/white"
                    app:tabGravity="fill"
                    app:tabIndicatorHeight="2dp"
                    app:tabMode="fixed"
                    app:tabSelectedTextColor="@android:color/black"
                    app:tabTextColor="@android:color/black" />
            </android.support.design.widget.AppBarLayout>
            <android.support.v4.view.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                   />
        </android.support.design.widget.CoordinatorLayout>
    </RelativeLayout>
 </android.support.v4.widget.NestedScrollView>
 </RelativeLayout>

任何人都可以告诉我该怎么做。我的屏幕设计如下所示。我添加两个水平滚动RecyclerView上下布局有两个像图像的选项卡 ScreenDesign

1 个答案:

答案 0 :(得分:0)

尝试在NestedScrollView之外设置AppBarLayout。

检查API文档以了解CoordinatorLayout,AppBarLayout和NestedScrollView的嵌套 Here