0

I have this code:

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipeContainer"
    xmlns:design="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:weightSum="1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:theme="@style/Theme.AppCompat"
    tools:context="com.tag.instagramdemo.example.MainActivity"
    android:background="@drawable/background1">

    <ListView

        android:id="@+id/lvRelationShip"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

    </ListView>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="bottom"
android:background="#ffffff"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:itemIconTint="@color/text"
android:enabled="false"
app:itemTextColor="@color/text"
android:animateLayoutChanges="true"
android:clickable="false"
design:menu = "@menu/menu_main"
android:contextClickable="false"/>    

When I use this layout. I can't see the bottom bar and I can only see the listview. At the top there is the list and nothing else.

Prafulla Malviya
  • 375
  • 3
  • 17

2 Answers2

0

I tried to resolve your issue. I hope it will work for you :) Please have a look and tried

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:design="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeContainer"
        android:layout_above="@+id/bottomBar"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:theme="@style/Theme.AppCompat"
        android:weightSum="1">

        <ListView

            android:id="@+id/lvRelationShip"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

        </ListView>

    </android.support.v4.widget.SwipeRefreshLayout>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        android:animateLayoutChanges="true"
        android:background="#ffffff"
        android:clickable="false"
        android:contextClickable="false"
        android:enabled="false"
        design:menu="@menu/navigation" />
</RelativeLayout>
Prafulla Malviya
  • 375
  • 3
  • 17
0
  1. If you have not added a parent layout, do add a parent layout. Enclose the listview inside swiperefreshlayout and enclose the bottombar & swiperefreshlayout inside a parent layout (for eg., relative layout)

    <RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:design="http://schemas.android.com/apk/res-auto"
        ....>
        <android.support.v4.widget.SwipeRefreshLayout
            android:id="@+id/swipeContainer"
         ...>
    
             <ListView
                android:id=... >
             </ListView>
         </android.support.v4.widget.SwipeRefreshLayout>
    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottomBar"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:layout_gravity="bottom"
        android:background="#ffffff"
        android:enabled="false"
        app:itemIconTint="@color/colorAccent"
        app:itemTextColor="@color/colorPrimary"
        android:animateLayoutChanges="true"
        android:clickable="false"
        android:contextClickable="false"
        android:layout_below="@id/swipeContainer"
        app:menu = "@menu/menu_main"/>
    

  2. Also use

app:menu

instead of design:menu as suggested in https://medium.com/@chornenkyy.v/first-look-at-bottomnavigationview-from-android-design-library-8244de85b953

BottomNavigationView has a method inflateMenu(menu) and if you pass your menu resource file inside it will work. Right after idea with the wrong namespace appear in my mind so I tried to replace ‘design’ with ‘app’ namespace which automatically resolves the attributes. And it actually works. The same story for other three attributes which exist specifically for this view: itemBackground, itemIconTint, itemTextColor.

anoo_radha
  • 812
  • 1
  • 15
  • 34