0

我将 BottomNavigationView 用于底栏,并在一个活动中显示 listView 中的对象列表。但是我应用于该活动的底栏阻碍了 listView 的最后一个元素。

在此处输入图像描述

从图像中可以看出,最后一个列表元素被底栏挡住了(最后一个元素所在的城市不可见)。

如何解决这个问题并在没有底栏干预的情况下正确显示列表元素。这是xml代码:

<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>
4

2 回答 2

2

您应该使带有 id 的布局cust_dtl位于 上方BottomNavigationView,现在您的列表视图位于底部导航视图的后面,这就是您看不到最后一行的原因

试试这个解决方案:

 <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>
于 2018-01-30T08:34:52.017 回答
2

像这样做。

<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>
于 2018-01-30T08:47:45.960 回答