Search code examples
androidandroid-relativelayoutz-order

Android RelativeLayout Z Order Layering


I have an issue with my activity_main.xml in which the bottombar as shown in my layout below appears to cut off the bottom of my main fragment container and is layered on top of it instead of appearing below it.

The bottombar should appear below the main conatiner instead of layering above it.

Can someone please help me as I have tried everything.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    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/drawer_layout_new"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include
        android:id="@+id/my_toolbar"
        layout="@layout/toolbar">
    </include>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:id="@+id/fragmentContainerNew"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_above="@+id/bottomBar" />

        <com.roughike.bottombar.BottomBar
            android:id="@+id/bottomBarNew"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_alignParentBottom="true"
            app:bb_tabXmlResource="@xml/bottombar_tabs" />

    </RelativeLayout>

</LinearLayout>

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:menu="@menu/activity_main_drawer" />

bottom part of activity_main


Solution

  • You forgot to add proper id @+id/bottomBarNew, Change your value:

        <FrameLayout
            android:id="@+id/fragmentContainerNew"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentTop="true"
            android:layout_above="@+id/bottomBarNew" />  //<---here