首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >改变卷轴上collapsingToolbarLayout的颜色

改变卷轴上collapsingToolbarLayout的颜色
EN

Stack Overflow用户
提问于 2016-10-11 07:41:18
回答 1查看 3K关注 0票数 0

因此,我遇到了一个我找不到解决办法的问题,我对这个问题做了一个小片段。视频

我想要的是,一旦我滚动的collapsingToolbarLayout,颜色应该开始改变为工具栏的颜色,因为它发生在facebook应用程序。如您所见,当它覆盖collapsingToolbarLayout的3/4高度时,它就开始了。

XML:

代码语言:javascript
运行
复制
<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="280dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


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


        <RelativeLayout
            android:id="@+id/layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/imageV"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:adjustViewBounds="true"
                android:contentDescription="@null"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:transitionName="image"
                app:layout_collapseMode="parallax"
                tools:targetApi="lollipop" />

            <View
                android:id="@+id/view"
                android:layout_width="match_parent"
                android:layout_height="280dp"
                android:background="#200000" />

        </RelativeLayout>

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

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

感谢你的帮助。谢谢。

EN

回答 1

Stack Overflow用户

发布于 2016-10-11 20:08:52

CollapsingToolbarLayout有一个名为app:scrimVisibleHeightTrigger的属性

指定用于定义何时触发划线可见性更改的可见高度(以像素为单位)。

由于应用程序栏的高度为280 of,所以设置app:scrimVisibleHeightTrigger="240dp"应该有效。

我不记得这是从顶部还是底部,所以如果这使得它真的改变了很晚,尝试app:scrimVisibleHeightTrigger="20dp"。无论如何,您应该能够调整该值,以获得您想要的外观。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39972491

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档