在CollapsingToolbarLayout中设置minHeight无效 [英] setting minHeight in CollapsingToolbarLayout not having any effect

查看:212
本文介绍了在CollapsingToolbarLayout中设置minHeight无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CollapsingToolbarLayout当前存在的主要问题是,无论我尝试什么,我的工具栏的minHeight属性都没有任何作用.

The main problem I've currently got with the CollapsingToolbarLayout is, that whatever I'm trying, the minHeight attribute of my Toolbar does not have any effect.

我想要的结果是: (CollapsingToolbarLayout具有一定的展开高度和一定的折叠高度(在示例中为180dp),而标题折叠或停留在顶部)

My desired result would be this: (The CollapsingToolbarLayout with a certain expanded height and a certain collapsed height (in the example 180dp), while the title either collapses or stays on the top)

但是无论我做什么,标题有时都在中间,不会完全折叠,或者无论如何都会忽略minHeight.我试图通过Web上找到的各种方法设置AppBarLayout,CollapsingToolbarLayout,工具栏本身,任何内容等的minHeight,但是没有运气.

But whatever I do, the title sometimes is in the center, won't completely collapse or the minHeight is ignored anyway. I have tried to set the minHeight for either AppBarLayout, CollapsingToolbarLayout, the toolbar itself, any contents, etc. also with different approaches found on the web but with no luck.

这是基本的xml:

<android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:minHeight="180dp">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            app:contentScrim="@android:color/transparent"
            app:expandedTitleGravity="bottom"
            app:expandedTitleTextAppearance="@style/TextAppearence.App.ToolbarTitle"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:statusBarScrim="@android:color/transparent">

            <com.xxxxxx.custom.Banner
                android:id="@+id/parallax_image"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:adjustViewBounds="true"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/xxxxxxxx"
                app:layout_collapseMode="parallax"
                app:layout_collapseParallaxMultiplier="0.6"
                app:layout_scrollFlags="scroll" />

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:minHeight="180dp"
                app:layout_collapseMode="pin" />

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

我希望这足以解释我的问题. 感谢您的任何帮助,谢谢!

I hope this is enough content to explain my problem. Any help is appreciated, thanks!

推荐答案

您可以将高度设置为180dp而不是使用minHeight,然后将TextView添加到工具栏中以用作标题.

You can set the height to 180dp instead of using minHeight, and then add a TextView into the toolbar to serve as the title.

这篇关于在CollapsingToolbarLayout中设置minHeight无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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