I know this has been asked frequently, but I haven't found what I exactly need.
What I'm aiming to is the following:
- One activity, the main layout should contain three tabs using tab layout and view pager.
- This same layout must have Drawer layout and navigation view.
- I want the 3 tabs in the main layout to be in a coordinator layout as I want it to coordinate as I scroll in my list.
- When I select something from the drawer layout I want the whole screen (except the toolbar) to be replaced with a fragment depending on what was chosen.
I have tried:
- This link but what he does is separate the tab layout from the toolbar, making the toolbar no coordinating I guess. i.e when he swipes through the list the toolbar won't get hidden.
I have tried this code as well(No coordinator layout yet):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:theme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_scrollFlags="scroll|enterAlways" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_main"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
</LinearLayout>
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/drawer_menu"/>
But when I choose an item from the drawer, I replace the fragment on the frame layout, this is what I get: The new layout contains a text view only. And as you can see, the frame layout doesn't cover the whole screen, but it is placing the text view on top of my layout
EDIT: When I choose an item in the drawer, I want the tabs to be hidden or disappear and only the toolbar should remain