0

У меня есть TabLayout, ниже SwipeRefreshLayout, содержащий ViewPager (на каждой странице есть RecyclerView). Раньше я использовал SRL в каждом фрагменте страницы, но теперь менял ее, поэтому у меня есть только один способ, который удобнее. По какой-то причине ViewPager отключается, и я не могу прокрутить весь путь до вершины RecyclerView.ViewPager отключен

У кого-нибудь есть решение?

enter image description here

Вот мой макет XMLs: 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> 

ответ

1

Заменить RelativeLayout на LinearLayout в вашем activity_main.

+0

Спасибо! Слишком очевидно, что я об этом не думал. – Crosswind

+0

Не забудьте добавить ориентацию = «вертикальная»;) – king

+0

Да, я уже сделал это, ха-ха, спасибо! – Crosswind

Смежные вопросы