Android 带有支持库的可折叠应用程序栏高程问题

Android 带有支持库的可折叠应用程序栏高程问题,android,android-layout,android-support-library,android-collapsingtoolbarlayout,android-appbarlayout,Android,Android Layout,Android Support Library,Android Collapsingtoolbarlayout,Android Appbarlayout,我对新材料设计支持库中的应用程序栏有问题。我的问题是,CollasingToolbarLayout的标高与工具栏顶部的标高不同。以下是布局的XML代码: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:la

我对新材料设计支持库中的应用程序栏有问题。我的问题是,CollasingToolbarLayout的标高与工具栏顶部的标高不同。以下是布局的XML代码:

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true"
    android:elevation="25dp">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        app:contentScrim="?attr/colorPrimary"
        app:expandedTitleMarginStart="48dp"
        app:expandedTitleMarginEnd="64dp"
        android:fitsSystemWindows="true">

        <com.example.example.widgets.CustomImageView
            android:id="@+id/image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scaleType="centerCrop"
            android:fitsSystemWindows="true"
            app:layout_collapseMode="parallax"/>

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

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

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

<android.support.v4.widget.NestedScrollView
    android:id="@+id/scroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.CardView
            ...>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <TextView
                    .../>

                <TextView
                    .../>

            </LinearLayout>

        </android.support.v7.widget.CardView>

    </FrameLayout>

</android.support.v4.widget.NestedScrollView>

<android.support.design.widget.FloatingActionButton
    ... />
最后,这里是我的问题的截图:

同样,问题是钢筋的下半部分(塌陷部分)不在同一高程。任何关于如何解决这一问题的建议都是非常好的

谢谢


编辑:

这是我更新的活动图像:


除了标题之外的所有内容现在都消失了

我认为您应用于此活动的主题已经有了一个操作栏。如果要使用工具栏并将其设置为操作栏,请使用NoActionBar主题。

使用折叠工具栏时,不必在操作栏中设置标题,它只在折叠工具栏中设置

//This one is not needed
//getSupportActionBar().setTitle("App Name");

collapsingToolbar.setTitle("App Name");

如何做到这一点并保留应用程序栏的标题和下拉菜单?将Theme.AppCompat.NoActionBar应用于Android清单文件中的此活动,并使用setSupportActionBar方法将工具栏设置为ActionBar。这非常有效,但是现在我的AppBar没有显示我的后退按钮或任何菜单项…你正在调用setSupportActionBar方法吗?是的。现在,我的操作栏显示正常,但我的所有内容都没有了标题(我在折叠工具栏布局上设置了标题)。有没有办法在工具栏或折叠工具栏布局上设置菜单项和后退按钮?
//This one is not needed
//getSupportActionBar().setTitle("App Name");

collapsingToolbar.setTitle("App Name");