Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 嵌套在片段中的ScrollView,带有TabLayout&;ViewPager无法滚动_Android_Android Fragments_Android Viewpager_Android Scrollview_Android Tablayout - Fatal编程技术网

Android 嵌套在片段中的ScrollView,带有TabLayout&;ViewPager无法滚动

Android 嵌套在片段中的ScrollView,带有TabLayout&;ViewPager无法滚动,android,android-fragments,android-viewpager,android-scrollview,android-tablayout,Android,Android Fragments,Android Viewpager,Android Scrollview,Android Tablayout,我在片段中添加了NestedScrollView,如下代码片段所示 我正在使用FragmentPagerAdapter在ViewPager中显示片段内容。(以下) 内容正在正确填充,但我无法滚动 main_fragment.xml <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" an

我在片段中添加了NestedScrollView,如下代码片段所示

我正在使用FragmentPagerAdapter在ViewPager中显示片段内容。(以下)

内容正在正确填充,但我无法滚动

main_fragment.xml

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="1"
        android:background="@color/feed_grey_background" >

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/default_gap_1_5x">
        </LinearLayout>

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

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="@android:color/holo_blue_light" />

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

tabview_fragment.xml

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:weightSum="1"
        android:background="@color/feed_grey_background" >

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/default_gap_1_5x">
        </LinearLayout>

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

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="@android:color/holo_blue_light" />

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

更新


如果我删除
recyclerView.setNestedScrollingEnabled(false),我可以滚动回收器视图(而不是nestedscrollview)

@Andev没有运气。那么它必须是类似-->的东西。不过,最简单的解决方案是防止嵌套滚动元素。@Andev感谢您的共享,但我的要求已更改,我不再使用该布局。我会检查它,并在这里更新,当我有时间。