0

I am using BottomNavigationView for bottom bar, and in an activity I am showing a list of objects in a listView. But the bottom bar that I have applied to that activity is obstructing the last element of the listView..

enter image description here

As you can see from the image that the last list element is being obstructed by the bottom bar (city of the last element is not visible).

How to resolve this and show the list elements properly without the intervention of the bottom bar. Here is the xml code:

<android.support.constraint.ConstraintLayout 
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="com.example.vendorapp.Promotion">

<RelativeLayout
    android:id="@+id/mainrlot"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/cust_dtl"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:visibility="invisible">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Customer List"
            android:textColor="#000000"
            android:textSize="30sp" />

            <ListView
                android:id="@+id/cstmrListView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:divider="@android:color/transparent"
                android:stackFromBottom="false"
                android:transcriptMode="alwaysScroll"
                tools:layout_editor_absoluteX="8dp"
                tools:layout_editor_absoluteY="24dp"
                tools:listitem="@layout/customer_list" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="end of result"
                android:textSize="20sp"/>

      </LinearLayout>   
     </RelativeLayout>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_marginEnd="0dp"
    android:layout_marginStart="0dp"
    android:background="?android:attr/windowBackground"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>
Achy97
  • 994
  • 1
  • 14
  • 29
  • have you added your RelativeLayout above BottomNavigationView? – Shrikant Jan 30 '18 at 08:37
  • yes as the BottomNavigationView is not showing if i keep it inside that – Achy97 Jan 30 '18 at 08:38
  • can you try like this: parent will be RelativeLayout, BottomNavigationView will set to parentBottom, LinearLayout with id = cust_dtl will be match_parent for both width & height and it will be above your BottomNavigationView. – Shrikant Jan 30 '18 at 08:43

2 Answers2

2

You should make the layout with id cust_dtl to be above the BottomNavigationView, right now your listview goes behind the bottom navigation view, that is why you don`t see the last row

Try this for a solution:

 <RelativeLayout
  android:id="@+id/mainrlot"
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  xmlns:app="http://schemas.android.com/apk/res-auto">

  <android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    android:layout_alignParentBottom="true"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginEnd="0dp"
    android:layout_marginStart="0dp"
    android:background="?android:attr/windowBackground"/>

  <LinearLayout
    android:id="@+id/cust_dtl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/navigation"
    android:orientation="vertical"
    android:visibility="invisible">

    <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="center"
      android:text="Customer List"
      android:textColor="#000000"
      android:textSize="30sp"/>

    <ListView
      android:id="@+id/cstmrListView"
      app:layout_editor_absoluteX="8dp"
      app:layout_editor_absoluteY="24dp"
      app:listitem="@layout/customer_list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:divider="@android:color/transparent"
      android:stackFromBottom="false"
      android:transcriptMode="alwaysScroll"/>

    <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="end of result"
      android:textSize="20sp"/>

  </LinearLayout>


</RelativeLayout>
DPE
  • 218
  • 5
  • 15
  • cannot do that as bottom bar and that linear layout are not siblings of a particular view – Achy97 Jan 30 '18 at 08:37
  • You can maybe remove the `ConstraintLayout` and add the bottom nav view inside your relative layout. Then they will be siblings and problem solved :) – DPE Jan 30 '18 at 08:40
  • The bottombar dose not show up if it is not the direct child of constraint layout @Darko – Achy97 Jan 30 '18 at 08:44
  • @AyanChowdhury look at my updated answer, maybe my code will help – DPE Jan 30 '18 at 08:46
  • @AyanChowdhury i checked the code and it should work.. if it does accept this answer and good luck ;) – DPE Jan 30 '18 at 08:54
  • i have another problem with this BottomNavigationBar , which i will be posting in a while -please answer if you can – Achy97 Jan 30 '18 at 09:05
2

Do it like this.

<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="com.example.vendorapp.Promotion">
    <LinearLayout
        android:id="@+id/cust_dtl"
        android:layout_above="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:visibility="invisible">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Customer List"
            android:textColor="#000000"
            android:textSize="30sp" />

        <ListView
            android:id="@+id/cstmrListView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:divider="@android:color/transparent"
            android:stackFromBottom="false"
            android:transcriptMode="alwaysScroll"
            tools:layout_editor_absoluteX="8dp"
            tools:layout_editor_absoluteY="24dp"
            tools:listitem="@layout/customer_list" />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="end of result"
            android:textSize="20sp"/>

    </LinearLayout>

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?android:attr/windowBackground"
    android:layout_alignParentBottom="true"
    app:menu="@menu/navigation" />
</RelativeLayout>
Atendra Singh
  • 396
  • 3
  • 9