Achy97
Achy97

Reputation: 1024

BottomNavigationView from Android Support Library Obstructing the Views

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>

Upvotes: 0

Views: 383

Answers (2)

Atendra Singh
Atendra Singh

Reputation: 396

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>

Upvotes: 2

DPE
DPE

Reputation: 228

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>

Upvotes: 2

Related Questions