Xml 安卓工作室;Kotlin:ListView赢得';t在坐标布局中使用锚固定在安装杆下方

Xml 安卓工作室;Kotlin:ListView赢得';t在坐标布局中使用锚固定在安装杆下方,xml,android-studio,listview,kotlin,Xml,Android Studio,Listview,Kotlin,各位程序员 我有一个listView,我无法在CoordinatorLayout(使用layout_锚定)中固定在appbar下方 这是我的xml: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http

各位程序员

我有一个listView,我无法在CoordinatorLayout(使用layout_锚定)中固定在appbar下方

这是我的xml:

<?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:fitsSystemWindows="true"
    tools:context=".UserSettings">

    <Button
        android:id="@+id/back_and_save"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="speichern und zurück" />

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:toolbarId="@+id/toolbar">

            <TextView
                android:id="@+id/username"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal|center_vertical"
                android:autoSizeTextType="uniform"
                android:gravity="center_horizontal|center_vertical"
                android:text="@string/username" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_user_settings" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/switchUser"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        app:backgroundTint="@color/colorPrimary"
        app:layout_anchor="@id/app_bar"
        app:layout_anchorGravity="end"
        app:srcCompat="@android:drawable/ic_menu_edit" />

    <ListView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="?android:attr/actionBarSize"
        app:layout_anchor="@id/app_bar"
        app:layout_anchorGravity="bottom"
        />


</android.support.design.widget.CoordinatorLayout>

虽然在布局的文本编辑视图中似乎没有问题,但在设计视图中,布局锚“@id/app_bar”也会抛出错误:意外的资源类型:“id”应为:string

我尝试将android:fitsSystemWindows
更改为false,但没有效果


非常感谢您的帮助:)

缺少listview的行为,只需添加:


app:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”

认为您缺少listview应用程序的行为:layout\u behavior=“@string/appbar\u scrolling\u view\u behavior”是的,您是对的,这实际上就是解决方案!非常感谢!:)