Hello there.
I'm Gaffigan and welcome to my android tutorials.
In today's video we've been talking about collapsing toolbar.
So what is it.
It is a wrapper for a toolbar which gives a collapsing effect to an application bar.
So let's discover more about it.
Let's start with a new project Okay
so let's call the project collapsing toolbar tutorial
lots of the next button.
Again we're going to keep a minimum as the guest 15 why so that we can run our application on almost
100 percent of the devices running ongoing in the world.
Let's add the next button.
Let's start with an activity let's call a doctor.
The US may not do the
well understood it is building a project.
So let's wait.
Well the application is built and it's ready to go do user collapsing to our level.
We need to add a dependency.
So let's do that first.
So integrated so application greater.
And that's the dependency here.
So implementation come not Android not support design on a version which is twenty six point zero point
one.
Sorry.
Point one point zero.
Well let's addressing greater button.
Well the greatest thing and we reduce the collapse into the rollout.
So let's just close this file and let's close this and let's a sugar level of five letters may not exist.
Let's switch attacks mode.
Well let's get rid of this constraint loud because views are collapsing to by load bearing.
Now it should be coordinated dilemma.
So let's use that here.
So calling it allowed.
Let's are the pub bar here.
So our bar layout would match variant.
I dropped content on here.
We need to order collapsing toolbars.
So collapsing two of our loud with much Behrendt high drop content.
Okay let's start an Image view on takes you so image you were much better in Thai say 200.
DP Let's add an SA.
So we'll be needing an image resource so let's not so let's just copy this one.
Well let's us basically enjoyable food.
OK so going back to our project let's use the resource five years.
So I see room.
Let's check the preview once villages.
Bring it here.
So as you can see you've got a collapsing toolbar.
Let's add Dubai here.
So do bar with match bearing height.
These are and action both sides.
OK
well let's relate a team.
So Team people really up combat action bar.
OK.
We also need to provide nested scroll view view.
OK so let's dock which would match variant height March variant on let's order takes you in here.
Or just copy paste this one here.
So control X draw re.
So we've got a text it is.
Hello.
Okay.
Well to achieve that collapsing effect we need to add some more attributes.
So let's do that.
So let's scroll flags so scroll on exit under collapsed.
OK.
Similarly we need to add some more attributes and image view.
So let's.
Are those.
So up loud collapse mode.
So just pallets.
And similarly toolbar so up loud collapse mode then.
OK.
And we also need to add some more attributes in this nested scroll view.
So let's add those two up now behaviour was crawling.
Behavior lets out of gravity here.
So they'll gravity say center just to bring it in center.
Let's run our obligation and see what we've built so far so let's just close this and let's run it well
what obligations.
Running so let's have a look.
Okay.
Well as you can see the scroll is not photo globally we've made some mistakes so let's have a look.
Okay so we've added a new toolbar but in the settings we already have a default bar.
So let's remove that.
So coming to our manifest.
So let's change the team view.
So we don't need the action by neutralizing it ourselves.
So no action bar so which is team up going back and no option but.
OK.
So coming back to our main for example let's just run the application
our obligations running so let's have a look.
Let's cool it.
So as you can see it's going up but there is no change of color.
Know it doesn't look like action bar.
So let's add another attribute.
So coming back to our collapsing to a ball out so content scrim so let's us on color primary door.
Well let's run our obligations again.
Well now as you can see when we screwed it up it looks like an action bar but there is no tie do or
anything.
So let's add that to coming to our main activity.
But before that we do on an idea for the school opting to a bar layout.
So I'd say collapsing toolbar.
Just copy pasted so copy.
So coming to main activity to Java.
Let's create an instance of that collapsing toolbar low so collapse into the cloud.
Let's call it all out.
So fine to me but I've ordered I.T. and just possibly I.D. you.
So do the layout that set.
I do.
Let's call it collapsing toolbar OK.
Let's add some more values here.
So not set collapsed Title X color.
So in the action borders collapse that means when it looks like an action by a thin strip.
So then for that let's define the next color.
So get resources get color dot color so you got the accent similarly let's define the color of an action
what is expanding.
That means when the image is visible.
OK.
So set expanded color.
So get resources get color Android dot all dot color dot transferred.
Well we don't want to show any.
I do when the action bars expanded.
OK.
So going back to your main file.
Oh looks good.
Let's run an obligation again.
Well the application is running so let's have a look.
Get it scroll it up tonight as you can see when it's collapsed.
We can see our data in the action which was this thing sort of color so gobs and toolbar.
And when we expand it that I do disappears because you is adding the color is transparent.
OK.
And there is some padding on left and right.
So it's for me some scaling issue that image.
So that's got some attributes that so scaled type.
So you send to crawl let's run it obligation and have a look.
Well the applications both.
So let's check it again.
Again as you can see that net break bottoms worn smooth and let's cool it up on all diagonal visible.
That's going down.
Those vaunted images usable well not all local apps including whirlpool.
If you have any doubts anyway.
The intruder Robert Coleman unable to declare anybody.