如何对CollapsingToolbarLayout的扩展标题多行显示? [英] How I can multiline the expanded title of CollapsingToolbarLayout?

查看:481
本文介绍了如何对CollapsingToolbarLayout的扩展标题多行显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是下一个.我将使用相对较大的文本作为CollapsingToolbarLayout标题,因此我需要将其显示为多行模式.当我尝试通过setExpandedTitleTextAppearance()方法更改文本外观时,它不起作用.下一个是我使用的代码:

My problem is the next. I would use relatively large texts as CollapsingToolbarLayout title so I need to show it as multiline mode. When I try to change text appearance through the setExpandedTitleTextAppearance() method it doesn't work. The code who I used is the next:

<style name="ToolbarExpandedTitle">
    <item name="android:textSize">48sp</item>
    <item name="android:shadowColor">#ffffff</item>
    <item name="android:textColor">@android:color/white</item>
    <item name="android:singleLine">false</item>
    <item name="android:minLines">3</item>
    <item name="android:lines">4</item>
    <item name="android:maxLines">5</item>
</style>

我希望多行显示标题,而不是显示省略号.

推荐答案

检出该库 multiline-collapsingtoolbar .

multiline-collapsingtoolbar替代 Android Design支持库中的CollapsingToolbarLayout 可以处理多行标题(当前硬编码最多3个) 行)处于展开状态.折叠工具栏时,下部 标题的各行逐渐消失,仅使第一行可见.

multiline-collapsingtoolbar is a replacement for CollapsingToolbarLayout from the Android Design Support Library which can deal with multiline titles (currently hard-coded to a maximum of 3 lines) in the expanded state. When collapsing the toolbar, the lower lines of the title fade away to leave only the top line visible.

作为设计支持库,它应与API 7(Android 2.1)及更高版本兼容

As the Design Support Library, it should be compatible with API 7 (Android 2.1) and above

这篇关于如何对CollapsingToolbarLayout的扩展标题多行显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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