0
我有一个TabLayout,在包含ViewPager的SwipeRefreshLayout下面(每个页面都有一个RecyclerView)。我曾经在每个页面片段中都有SRL,但现在改变了它,所以我只有一个更方便的方法。 由于某种原因,ViewPager被切断,我无法一直滚动到RecyclerView的顶部。ViewPager被切断
有没有人有解决方案?
这里是我的布局个XML: activity_main.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"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.TabLayout
android:id="@+id/mainTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabGravity="fill" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/mainSwipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/mainViewPager"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@id/mainTabLayout" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
片段布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/mainRecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
谢谢!太明显了,我没有想到这一点。 – Crosswind
不要忘记添加方向=“垂直”;) – king
是的,我已经做到了,哈哈感谢寿! – Crosswind