在我的应用程序中,我想将ViewPager显示为NestedScrollView,然后编写以下代码。

给我显示TabLayout,但不给我显示ViewPager

我的XML代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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

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

            <app.test.Componenets.PlusTabLayout.TabLayoutPlus
                android:id="@+id/celebrityMovieFrag_tabLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:minHeight="?attr/actionBarSize"
                android:paddingBottom="@dimen/size3"
                android:paddingLeft="@dimen/size3"
                android:paddingRight="@dimen/size3"
                app:tabIndicatorColor="@color/colorAccent"
                app:tabSelectedTextColor="@color/colorAccent"
                app:tabTextAppearance="@style/allCapsTabLayout"
                app:tabTextColor="@color/darkBlueGrey" />

            <app.test.Componenets.DisableSwipeViewPager
                android:id="@+id/celebrityMovieFrag_viewPager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/celebrityMovieFrag_tabLayout" />

        </RelativeLayout>

    </android.support.v4.widget.NestedScrollView>

</RelativeLayout>


我该如何解决这个问题?

最佳答案

当您将布局放在ScrollViewNestedScrollView中时,请始终使用一个<LinearLayout>并在其上放置所有其他布局。试试这个代码

<RelaytiveLayout>

   <android.support.v4.widget.NestedScrollView>

      <LinearLayout>
           //put your layout here
      <LinearLayout>

   </android.support.v4.widget.NestedScrollView>

</RelaytiveLayout>

09-06 04:19
查看更多