首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >CollapsingToolbarLayout安卓中的多行扩展标题?

CollapsingToolbarLayout安卓中的多行扩展标题?
EN

Stack Overflow用户
提问于 2015-11-21 07:51:00
回答 2查看 4.9K关注 0票数 7

如何使多行标题在CollapsingToolbarLayout中像..。whatsapp

我的XML文件

代码语言:javascript
运行
复制
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/detail_backdrop_height"
        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="16dp"
            app:expandedTitleMarginStart="16dp"
            app:expandedTitleTextAppearance="@style/HeaderTitleStyle"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">


                    <ImageView
                        android:id="@+id/cover_image"
                        android:layout_width="match_parent"                             android:layout_height="@dimen/detail_backdrop_height"
                        android:background="@color/white"
                        android:fitsSystemWindows="true"
                        android:scaleType="fitXY"
                        android:src="@drawable/default_clg_image"
                        app:layout_collapseMode="parallax" />


            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                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>
</android.support.design.widget.CoordinatorLayout>

expandedTitleTextAppearance

代码语言:javascript
运行
复制
app:expandedTitleTextAppearance="@style/HeaderTitleStyle"

,这是我的style.xml

代码语言:javascript
运行
复制
<style name="HeaderTitleStyle" parent="@android:style/TextAppearance">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:textSize">20sp</item>
    <item name="android:singleLine">false</item>
</style>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-01-24 15:24:37

我找到了一个很棒的库,名为multiline-collapsingtoolbar,它为您提供了一个可以处理多行标题的自定义折叠工具栏。

用法 库的公共API与支持库中的版本相同,因此您可以使用它作为插入替换。 作为设计支持库,它应该与API 7(Android2.1)和更高版本兼容。 XML布局示例: “ 您可以在demo模块中找到一个简单的演示应用程序。

票数 2
EN

Stack Overflow用户

发布于 2017-04-01 20:36:08

一种更简单的方法是将自定义布局添加到折叠工具栏中,并在折叠时将其钉住,这可能是最后的输出:

请看一下我的预览answer,看看完整的代码。

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

https://stackoverflow.com/questions/33841011

复制
相关文章

相似问题

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