16

Is it possible to make CollapsingToolbarLayout's expanded title text wraps across several lines (similar to TextView.maxLines attribute)?

Sokolof
  • 2,271
  • 2
  • 19
  • 30

3 Answers3

3

I did this with help from this library

https://github.com/opacapp/multiline-collapsingtoolbar

add the library to your project and replace the CollapsingToolbarLayout with net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout

2

In 2020, the feature you desired was added to CollapsingToolbarLayout. To activate it, simply use:

    app:maxLines="3"

Here's what it'll look like:

A multiline header title in an Android activity.

Fynn
  • 21
  • 5
0

I posted a solution on Android CollapsingToolbarLayout with custom View.

You can add the TextView, instead of a title inside your CollapsingToolbarLayout and change size/transition/color etc. with the help of the onOffsetChangeListner.

Community
  • 1
  • 1
Ciron
  • 226
  • 2
  • 6