(设计支持库)CollapsingToolbarLayout - 工具栏没有得到寄托在崩溃 [英] (Design Support Library) CollapsingToolbarLayout -- Toolbar not getting pinned on collapse
问题描述
我无法整合设计支持库到我的应用程序。出于某种原因,该工具栏崩溃与CollapsingToolbarLayout,并且不让它像寄托在Cheesesquare例如由克里斯·巴内斯。 https://github.com/chrisbanes/cheesesquare
我没做什么不同我的布局。事实上,我代替我的风格与他,并放置在他的布局。我不知道是否使用工具栏,而不是android.support.v7.widget.Toolbar的是导致此。
这是问题所在。
下面是我的AppBar部分的XML。
< android.support.design.widget.CoordinatorLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:程序=http://schemas.android.com/apk/res-auto
机器人:ID =@ + ID / main_content
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:fitsSystemWindows =真正的>
< android.support.design.widget.AppBarLayout
机器人:ID =@ + ID / appbar
机器人:layout_width =match_parent
机器人:layout_height =@扪/ detail_backdrop_height
机器人:主题=@风格/ ThemeOverlay.AppCompat.Dark.ActionBar
机器人:fitsSystemWindows =真正的>
< android.support.design.widget.CollapsingToolbarLayout
机器人:ID =@ + ID / collapsing_toolbar
机器人:layout_width =match_parent
机器人:layout_height =match_parent
应用程序:layout_scrollFlags =滚动| exitUntilCollapsed
机器人:fitsSystemWindows =真
应用程序:contentScrim =?ATTR / colorPrimary
应用程序:expandedTitleMarginStart =48dp
应用程序:expandedTitleMarginEnd =64dp>
< ImageView的
机器人:ID =@ + ID /背景
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:fitsSystemWindows =真
应用程序:layout_collapseMode =视差/>
<工具栏
机器人:ID =@ + ID /工具栏
机器人:layout_width =match_parent
机器人:layout_height =?ATTR / actionBarSize
应用程序:popupTheme =@风格/ ThemeOverlay.AppCompat.Light
应用程序:layout_collapseMode =针/>
< /android.support.design.widget.CollapsingToolbarLayout>
< /android.support.design.widget.AppBarLayout>
...
< /android.support.design.widget.CoordinatorLayout>
您的直觉是正确的: CollapsingToolbarLayout
并使用支持依赖于你工具栏
- 它使用设置 CollapsingToolbarLayout
的最低高度(在许多其他事情)。您应该切换到使用工具栏
的支持版本,以确保最好的体验 CollapsingToolbarLayout
。
I'm having trouble integrating the Design Support Library into my application. For some reason, the toolbar collapses with the CollapsingToolbarLayout, and does not leave it pinned like in the Cheesesquare example by Chris Banes. https://github.com/chrisbanes/cheesesquare
I didn't do anything different to my layout. In fact, I replaced my styles with his, and dropped in his layout. I wonder if using Toolbar, instead of android.support.v7.widget.Toolbar is causing this.
Here is the problem.
Here is my XML of the AppBar section.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<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"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginStart="48dp"
app:expandedTitleMarginEnd="64dp">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<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.design.widget.CoordinatorLayout>
Your intuition was correct: CollapsingToolbarLayout
does rely on you using the support Toolbar
- it uses that to set the minimum height of the CollapsingToolbarLayout
(among many other things). You should switch to using the support version of the Toolbar
to ensure the best experience with CollapsingToolbarLayout
.
这篇关于(设计支持库)CollapsingToolbarLayout - 工具栏没有得到寄托在崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!