[英]Android ListView appearing underneath Toolbar
I am trying to put a ListView below a Toolbar (that has a Navigation Drawer). 我试图将ListView放在工具栏(具有导航抽屉)下面。 Currently, the ListView is appearing underneath the Toolbar rather than below it (see picture). 当前,ListView出现在工具栏的下方而不是下方(参见图片)。 How would I fix this? 我该如何解决?
activity_main.xml activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
</FrameLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer_view"/>
</android.support.v4.widget.DrawerLayout>
Thanks! 谢谢!
Change FrameLayout
to a LinearLayout
with android:orientation="vertical"
as an attribute. 将android:orientation="vertical"
作为属性,将FrameLayout
更改为LinearLayout
。
As a side note you should be using RecyclerView
instead of a ListView
附带说明,您应该使用RecyclerView
而不是ListView
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.