[英]How to keep the background of CollapsingToolbarLayout as the background of ToolBar even when collapsed
My ToolBar position is always fixed at the top of the screen. 我的ToolBar位置始终固定在屏幕顶部。 The background image of the CollapsingToolbarLayout should always move behind the ToolBar.
CollapsingToolbarLayout的背景图像应始终移动到ToolBar后面。 also at the same time, the toolbar should be transparent and should use the background of CollapsingToolbarLayout as its background.
同时,工具栏应该是透明的,并应使用CollapsingToolbarLayout的背景作为其背景。
I made toolBar as transparent, my problem is, when CollapsingToolbarLayout is completely collapsed, my toolbar background is getting changed to color of "contentScrim". 我使toolBar变得透明,我的问题是,当CollapsingToolbarLayout完全折叠时,我的工具栏背景将变为“contentScrim”的颜色。 Why is this happening, how can i still keep the background of my CollapsingToolbarLayout as background of ToolBar event after completely collapsed.
为什么会发生这种情况,我怎么能在完全折叠后将CollapsingToolbarLayout的背景保留为ToolBar事件的背景。 In my case the bottom of background of CollapsingToolbarLayout should be the background of ToolBar when its completely collapsed
在我的情况下,CollapsingToolbarLayout的背景底部应该是ToolBar完全折叠后的背景
This is the code i have currently 这是我目前的代码
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed" android:background="@drawable/profilepic">
<android.support.v7.widget.Toolbar android:id="@+id/toolbarid"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"> <!-- android:color/transparent --><!--android:background="@color/primary"-->
<!--Toolebar layout goed here-->
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
I have solved this by keeping the 我通过保持这个来解决这个问题
app:contentScrim="@android:color/transparent"
in stead of 代替
app:contentScrim="@color/colorPrimary"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.