Android AppBarLayout重叠listview

OLe*_*ert 16 android listview android-appbarlayout

我正在编写一个与ContentProvider一起使用的简单应用程序,我有一个db,一个ContentProvider,一个主要活动,一个使用ContentResolver将命令转发到ContentProvider的类.在gui上我只想显示存储在db中的所有项目.我从头开始创建这个项目,在创建Activity时,主要布局有一个CoordinatorLayout,带有AppBarLayout,没关系,我创建了一个ListView,除了appBarLayout重叠ListView,在listview的第一项下面,一切正常被AppBarLayout隐藏. 在此输入图像描述

我尝试使用android:layout_below我的ListView,但它不起作用,如果我使用android:layout_marginTop然后我的ListView是在AppBarLayout下,但我没有找到这个解决方案很好.

在AppBarLayout下有没有干净简单的方法来获取ListView?

在我的activity_main布局下面:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    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"
    android:background="@color/holo_light_background"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <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/AppTheme.AppBarOverlay"
            app:popupTheme="@style/AppTheme.PopupOverlay" />
    </android.support.design.widget.AppBarLayout>


    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/bar"/>


    <android.support.design.widget.FloatingActionButton ...>

    <android.support.design.widget.FloatingActionButton ...>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

m.z*_*der 35

简单添加

app:layout_behavior="@string/appbar_scrolling_view_behavior"
Run Code Online (Sandbox Code Playgroud)

到您的ListView