opacapp / multiline-collapsingtoolbar

A modified CollapsingToolbarLayout that can deal with multiline titles
Other
783 stars 114 forks source link

Execute multi line->single line transition during content scrim animation #34

Open dmfs opened 7 years ago

dmfs commented 7 years ago

I'd like to execute the multi line to single line transition in an automated animation, synchronized with the content scrim animation, instead of gradually morphing from multi line to single line. Is there any way to achieve that?

johan12345 commented 7 years ago

One would need to add something to this listener that then influences the blending of the text. Currently, this is done here instead depending on the scrolling position.

If you'd implement this and make the behavior switchable between the current animation and this version using a method in CollapsingToolbarLayout, we would accept that as a pull request.

dmfs commented 7 years ago

I've implemented something that works for us. At present it can't be disabled but I think that shouldn't be hard to do. Do you have any preference for an xml attribute name to switch this behavior?

 <net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout
        ...
    app:collapseMode = "onScrim"
 >
...

With the values onScroll (the default) and onScrim?

johan12345 commented 7 years ago

Maybe something like textCollapseMode would be more clear. @raphaelm, what do you think?

raphaelm commented 7 years ago

Or even textCollapseOn with the values scroll and scrim?

johan12345 commented 7 years ago

Yeah, that's fine too.

dmfs commented 7 years ago

My idea was to target a broader scope with that field and not just the title text. We have implemented another extension that could be affected by this setting. The other extension allows you to specify for each child element how it behaves during content scrim. We've called it scrimMode and it's applied to the child elements. The values are none (the default) which keeps the current behavior, out which fades the element out on scrim and in which fades the element in. The transitions can be executed while scrolling or when the scrim animation is started.

We use it to switch between a white themed toolbar and a dark themed toolbar during the scrim animation. The scrim changes the appearance of our toolbar from a dark background to a white one. So we have two toolbars and x-fade them during the scrim animation (or optionally as per collapseMode, while scrolling)

dmfs commented 7 years ago

I've just opened PR #38 As you see I've taken the orthogonal approach. I've added a flag to specify which elements should be auto-animated and which should be gradually morphed.

you apply it like this

 <net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout
        ...
    app:autoAnimate = "title|scrim"
 >

You can also apply this

 <net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout
        ...
    app:autoAnimate = "none"
 >

Which means that the scrim is now applied gradually as you scroll.

There is another value called children but it's not implemented yet as it depends on PR #36.

I have a branch called "schedjoules" which will contain the changes of all three PRs. Let me know if you'd prefer a single PR with all the enhancements (with the conflicts already being resolved).