向上倾斜时,折叠的工具栏图像消失 [英] Collapsing Toolbar image disappearing when scolling up

查看:80
本文介绍了向上倾斜时,折叠的工具栏图像消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现带有大标题图像的折叠式工具栏.我希望图像开始很大(并且可以工作)并且不完全崩溃(也可以工作).问题在于,当工具栏达到最小可折叠高度时,图像会消失,并逐渐消失为应用程序的原色. 我希望图像即使折叠也能保持可见.

I am trying to implement a collapsing toolbar with a large header image. I want the image to start very big (and it works) and not collapse entirely (that works too). The problem is that when the toolbar reaches minimum collapsable height the image disappears, fading to the app's primary color. I want the image to stay visible even when collapsed.

此外,后退按钮与图片一起向上移动,我希望它可以固定在适当的位置.

Also, the back button is scolling up along with the picture, and I want it to keep fixed in place.

活动的xml:

    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                             xmlns:app="http://schemas.android.com/apk/res-auto"
                                            android:layout_width="match_parent"
                                            android:layout_height="match_parent"
                                            android:fitsSystemWindows="true">         <android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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:layout_scrollFlags="scroll|exitUntilCollapsed">

    <ImageView
        android:id="@+id/imageViewToolbar"
        android:minHeight="500dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:scaleType="centerCrop"
        app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
        app:layout_collapseMode="parallax" />

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:title=""
        android:layout_width="match_parent"
        android:layout_height="300dp"
        app:layout_scrollFlags="scroll|enterAlways"
         />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/detail_content"/>

谢谢.

推荐答案

我已修复:

我通过在CollapsingToolbarLayout中添加app:statusBarScrim="@android:color/transparent"来使图像不褪色为纯色,并通过在工具栏的布局中添加app:layout_collapseMode="pin"来修复后退按钮向上滑动的情况.

I made the image not fade to a solid color by addding app:statusBarScrim="@android:color/transparent" to the CollapsingToolbarLayout and I fixed the back button sliding up by adding app:layout_collapseMode="pin" to the Toolbar's layout.

这篇关于向上倾斜时,折叠的工具栏图像消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆