【发布时间】:2018-08-18 06:58:08
【问题描述】:
我有一个布局,顶部有一个搜索栏,一个列表视图,然后是一个底部导航视图。问题是,列表视图的最后一项隐藏在底部导航视图的后面。
这是布局的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:id="@+id/rel1"
>
<RelativeLayout
android:id="@+id/relLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/snippet_searchbar" />
</RelativeLayout>
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/relLayout1"
android:scrollbars="vertical">
</ListView>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/relLayout1" />
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_gravity="bottom|end"
android:layout_marginBottom="27dp"
android:layout_marginEnd="27dp"
android:src="@drawable/ic_next" />
<include layout="@layout/layout_bottom_navigation_view"
/>
</RelativeLayout>
对于底部导航视图:
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true">
<com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/bottomNavViewBar"
android:background="@drawable/white_grey_border_bottom"
app:menu="@menu/bottom_navigation_menu"
app:itemIconTint="@color/secondaryLightColor"
>
</com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx>
</RelativeLayout>
</merge>
如何解决此问题,以便底部导航视图显示在列表视图下方,并且带有滚动条的列表视图的最后一项显示在底部导航上方,即使滚动到底部也是如此。
【问题讨论】:
-
尝试添加一些
android:paddingBottom="30dp" -
您可以尝试
LinearLayout而不是RelativeLayout并将方向设置为垂直,这样它会自动将您的视图排列在一个下方。
标签: android android-layout listview android-relativelayout