In my app I have my main page, in it a ViewPager. I can navigate between fragments in the ViewPager using a drawerLayout. One of the fragments is a RecyclerView (in a FrameLayout). The problem is I cannot scroll the RecyclerView.
I've asked a question of the sort before, and got the solution, only it was a ScrollView instead of RecyclerView, and the ViewPager was in a ConstraintLayout, and now it has to be in a RelativeLayout so the drawerLayout could exist.
code of the layouts:
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/mainScreenContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimary"
tools:context=".MainActivity">
<include
android:id="@+id/mainToolbar"
layout="@layout/main_toolbar_layout" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/mainTabLayout"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone">
<com.google.android.material.tabs.TabItem
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="0dp" />
<com.google.android.material.tabs.TabItem
android:id="@+id/activeGoals"
android:layout_width="match_parent"
android:layout_height="0dp" />
<com.google.android.material.tabs.TabItem
android:id="@+id/achievedGoals"
android:layout_width="match_parent"
android:layout_height="0dp" />
<com.google.android.material.tabs.TabItem
android:id="@+id/stats"
android:layout_width="match_parent"
android:layout_height="0dp" />
<com.google.android.material.tabs.TabItem
android:id="@+id/tipsAndTricks"
android:layout_width="match_parent"
android:layout_height="0dp" />
<com.google.android.material.tabs.TabItem
android:id="@+id/aboutUs"
android:layout_width="match_parent"
android:layout_height="0dp" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/mainViewPager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentBottom="true"
android:layout_below="@id/mainToolbar"/>
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:layout_below="@id/mainToolbar">
<com.google.android.material.navigation.NavigationView
android:id="@+id/list_nav_drawer"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/menu_items" />
</androidx.drawerlayout.widget.DrawerLayout>
</RelativeLayout>
fragment_active_goals.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".ActiveGoals">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/activeGoalsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
I'd want the RecyclerView to be scrollable. thanks in advance (: