繁体   English   中英

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

[英]How to keep the background of CollapsingToolbarLayout as the background of ToolBar even when collapsed

我的ToolBar位置始终固定在屏幕顶部。 CollapsingToolbarLayout的背景图像应始终移动到ToolBar后面。 同时,工具栏应该是透明的,并应使用CollapsingToolbarLayout的背景作为其背景。

我使toolBar变得透明,我的问题是,当CollapsingToolbarLayout完全折叠时,我的工具栏背景将变为“contentScrim”的颜色。 为什么会发生这种情况,我怎么能在完全折叠后将CollapsingToolbarLayout的背景保留为ToolBar事件的背景。 在我的情况下,CollapsingToolbarLayout的背景底部应该是ToolBar完全折叠后的背景

这是我目前的代码

    <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>

我通过保持这个来解决这个问题

    app:contentScrim="@android:color/transparent"

代替

    app:contentScrim="@color/colorPrimary"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM