multiline-collapsingtoolbar icon indicating copy to clipboard operation
multiline-collapsingtoolbar copied to clipboard

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

Open dmfs opened this issue 7 years ago • 7 comments

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?

dmfs avatar Apr 03 '17 18:04 dmfs

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.

johan12345 avatar Apr 06 '17 10:04 johan12345

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?

dmfs avatar Apr 06 '17 10:04 dmfs

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

johan12345 avatar Apr 06 '17 12:04 johan12345

Or even textCollapseOn with the values scroll and scrim?

raphaelm avatar Apr 06 '17 13:04 raphaelm

Yeah, that's fine too.

johan12345 avatar Apr 06 '17 13:04 johan12345

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 avatar Apr 06 '17 13:04 dmfs

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).

dmfs avatar Apr 07 '17 13:04 dmfs