How to use custom list view with bottom navigation bar in android java?

Viewed 27

Unable to use bottom navigation in this code on full page on list view is visible

<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="wrap_content"
        android:orientation="vertical"
        android:theme="@style/Theme.AppTheme"
        app:titleTextAppearance="@font/montserrat_regular_400"
        tools:context=".AddedDevicesActivity">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="50dp"
        tools:listitem="@layout/list_item"
        android:layout_alignParentBottom="true">
    </ListView>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/white"
        app:menu="@menu/menu"/>

</RelativeLayout>

Unable to use bottom navigation in this code, On full page only list view is visible.

1 Answers

Try adding

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/bottomNavigationBar"
    tools:listitem="@layout/list_item">
</ListView>

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottomNavigationBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@color/white"
    app:menu="@menu/menu"/>
Related