Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - CollapsingToolbarLayout: Allow multiple lines of text in expanded state #6

Closed
johan12345 opened this issue Dec 16, 2016 · 12 comments
Assignees

Comments

@johan12345
Copy link
Contributor

Overview

CollapsingToolbarLayout currently only allows for a single line title. However, in the expanded state, there would be enough space to display multiple lines.

Multiple app developers (such as WhatsApp) have already built their own custom views as a replacement for CollapsingToolbarLayout to solve this issue. However, these are mostly closed-source, use different, inconsistent animations when expanding and collapsing, and/or are not usable as a drop-in replacement for CollapsingToolbarLayout because they have a different API.

We (@raphaelm and I, with help from some contributors) have built an open-source library that tries to solve this problem. It is based directly on the original CollapsingToolbarLayout/CollapsingTextHelper classes from the Design Support Library with only a few code changes and an additional maxLines attribute. In addition to that, we feel that the animation we use is more smooth than the one from e.g. WhatsApp.

Demo image

However, we had to copy quite a lot of files (basically all the classes that are referenced from CollapsingToolbarLayout) from the original support library when creating this library because they are package-private and therefore not accessible from our classes or because we needed access to private fields, which is not possible when extending a class. For this reason, it is quite tedious to keep our library up-to-date with changes from the support library.

Would you be interested in adopting our changes into the original library, e.g through a pull request? Or are you already working on the same feature?

There are some bugs in our library that occur when using text shadows or transparent text that we have not worked on ourselves because we don't use those features in our app, but they should be quite straightforward to resolve.

Related issues

@PattaFeuFeu
Copy link

PattaFeuFeu commented Dec 21, 2018

What’s the current status on this one? The Material guidelines state that multiple lines should be used and that the code for Android was readily available, however it doesn’t feature this option.

image

@johan12345
Copy link
Contributor Author

We are still struggling to update our multiline-collapsingtoolbar library to support Android 9 and the new Material Components and AndroidX libraries, because the @RestrictTo annotations prevent us from accessing many classes that we previously used from the Support Libraries. Thus, the only solution is be to finally implement this functionality into the main Material Components libraries...

@alex-dokienko
Copy link

guys, any plan to add such support in material components library?

@rion18
Copy link

rion18 commented Jun 26, 2019

Added this as a feature request on https://issuetracker.google.com/issues/136120586

@rion18
Copy link

rion18 commented Jun 28, 2019

It seems they can accept PRs. https://issuetracker.google.com/issues/136120586

@johan12345 It'd be awesome if this makes part of material.components !

@johan12345
Copy link
Contributor Author

Yep, we saw this already, one of the comments came from @raphaelm. I will try to implement this as a PR.

@rion18
Copy link

rion18 commented Jun 28, 2019

Brilliant. I can lend a hand if needed.

@johan12345
Copy link
Contributor Author

see #413

@cketcham cketcham self-assigned this Jul 9, 2019
johan12345 added a commit to opacapp/material-components-android that referenced this issue Jul 11, 2019
johan12345 added a commit to opacapp/material-components-android that referenced this issue Aug 1, 2019
johan12345 added a commit to opacapp/material-components-android that referenced this issue Aug 1, 2019
johan12345 added a commit to opacapp/material-components-android that referenced this issue Oct 1, 2019
johan12345 added a commit to opacapp/material-components-android that referenced this issue Oct 4, 2019
johan12345 added a commit to opacapp/material-components-android that referenced this issue Dec 4, 2019
@wcshi wcshi assigned ymarian and unassigned cketcham Dec 11, 2019
@ArcherEmiya05
Copy link

So is this feature already available in com.google.android.material:material:1.2.0-alpha03 ?

@johan12345
Copy link
Contributor Author

@ArcherEmiya05 Not as far as I can see - the last change to CollapsingToolbarLayout in the library was 5 months ago. See the PR #413 for the latest updates.

@ArcherEmiya05
Copy link

@ArcherEmiya05 Not as far as I can see - the last change to CollapsingToolbarLayout in the library was 5 months ago. See the PR #413 for the latest updates.

So there is no way to do this without needing to create your own xml layout?
Why is it already in the guidelines then? Just really confuse.

@johan12345
Copy link
Contributor Author

So there is no way to do this without needing to create your own xml layout?

There is, you can use our fork of the Material Components library until it's merged. But it might cause incompatibilities with other libraries that depend on the Material Components library and we will provide no support.

Why is it already in the guidelines then? Just really confuse.

Well, I'm not from Google, so I can't really answer that. The Material Components library doesn't have implementations for all the things that show up in the guidelines, but I guess something needs to be added to the guidelines first before an implementation can be included.

applimatix pushed a commit to applimatix/material-components-android that referenced this issue Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants