Search code examples
androidandroid-fragmentsandroid-viewpagerandroid-toolbarandroid-bottomnav

How to show ViewPager below of Toolbar in android


I want show some Fragments in my application and for this I want show viewPager and BottomNavigation.
I want show this viewPager below of Toolbar, I write below codes but not work me and not show toolbar!
MainPage codes:

<?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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="in.nouri.sevenwatchlist.Activities.MainActivity">

    <include
        android:id="@+id/mainToolbar"
        layout="@layout/toolbar_main" />

    <com.aurelhubert.ahbottomnavigation.AHBottomNavigationViewPager
        android:id="@+id/mainViewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/mainBottomNavigation"
        android:layout_alignParentTop="true"
        android:layout_below="@+id/mainToolbar"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <com.aurelhubert.ahbottomnavigation.AHBottomNavigation
        android:id="@+id/mainBottomNavigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        app:selectedBackgroundVisible="false" />

</RelativeLayout>

I use this code into viewPager, app:layout_behavior="@string/appbar_scrolling_view_behavior" but not work me again!

How can I fix it? Please help me


Solution

  • remove following property from viewpager and check

      android:layout_alignParentTop="true"