简体   繁体   English

如何将CollapsingToolbarLayout的背景保留为ToolBar的背景,即使在折叠时也是如此

[英]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.

相关问题 即使 CollapsingToolbarLayout 折叠,如何使 Toolbar 和 TabLayout 仍然可见? - How to make Toolbar and TabLayout still visible even when CollapsingToolbarLayout is collapsed? Android Material Design-CollapsingToolbarLayout折叠后如何更改工具栏的背景颜色 - Android Material Design - How to change background color of Toolbar after CollapsingToolbarLayout is collapsed 如何将RecyclerView放在CollapsingToolbarLayout下面并在Android中折叠时响应工具栏? - How to put RecyclerView below CollapsingToolbarLayout and responsive to toolbar when collapsed in Android? 在 CollapsingToolbarLayout 中折叠时如何删除透明的工具栏填充 - How to remove transparent Toolbar padding when collapsed in CollapsingToolbarLayout 未折叠时Android折叠工具栏的背景颜色 - Android Collapsing toolbar background color when not collapsed Android:使用ImageView工具栏背景的CollapsingToolbarLayout - Android: CollapsingToolbarLayout with ImageView Toolbar background CollapsingToolbarLayout折叠时未显示工具栏标题 - Toolbar Title not showing when CollapsingToolbarLayout collapsed 当CollapsingToolbarLayout折叠时,工具栏HOME不起作用 - Toolbar HOME not working when CollapsingToolbarLayout collapsed CollapsingToolbarLayout中的内容被工具栏背景颜色遮盖 - Top of content in CollapsingToolbarLayout obscured by Toolbar background colour 当CollapsingToolbarLayout折叠时,锚定图像会被工具栏重叠 - Anchor image gets overlapped by toolbar when CollapsingToolbarLayout is collapsed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM