Hello there.
I'm Gaffigan.
And welcome back to mom what you two rules in today's video we'll be talking about bottom sheets.
So what does a bottom sheet.
It is a view that slides up from the bottom of the screen to show more content.
So let's get started.
Let's create a new project and let's call it what she tutorials.
So bottom sheet tutorials.
Let's hit the next button again we're going to keep our known as the guest of the white so that we can
run our obligation almost a hundred percent of the devices running Android in the wall.
Let's go the next button.
Let's start with an empty activity.
Let's call our first IQ test Maina well under two years building up product so let's wait.
Well our products ready and we're good to go.
So let's move on to the layout file first and to use bottom sheets.
We'll be needing a coordinate allowed as a parent level and to use coordinate aloud with our plan and
dependency.
So let's add that first.
So obligation greater.
Let's other dependency here.
So implementation com not Android dot support and design.
And let's throw I the join you.
So twenty six point one 1 0.
Letting the greater allow Well the greetings is built on move we've to support design library.
So let's just close this on coming back to our e-mail file.
Let's get rid of this constrained layout.
Let's add the co-ordinator level to you.
Well let's start another layer for our bottom sheet.
Just to keep things clean you so project application resources and layout.
Right click new resource file.
So let's call it bottom sheet layout
so the key button.
Let's switch to the next mode unclothed us.
Well let's get rid of this constraint loud and use a linear allows you.
So.
Let's build an orientation.
So orientation say vertical and for this loud to be a bottom sheet level we need to define some level
behaviors.
So let's do that.
So are and that's important.
So it's done so loud behavior.
What machine behavior.
OK.
We need to add one more thing.
So let's do that.
So that behavior on peak height.
OK so let's build about literacy of six DP.
And what this behavior be high does is.
So whenever your bottom sheet is globs.
So this much height would be visible OK so let's create the content here.
So let's say TextView with much variance.
I'd say six DP to add some text we love to create a string so coming to values and string let's create
a string resource here so string let's say SDR sheet title let's call it drag me up.
That's another string resource.
So let's call it stripper sheet content.
Again let's call it Hello there.
OK.
So coming back to your bottom sheet loud example.
So let's rewind the text here which was a star.
Should I do.
Let's throw out a background color so background on droid colors a lot.
Let's change the decks color so text color Android color see white.
Well let's add another next review.
So TextView with much variant Heights a hundred DP.
Let's roll the text here so which was a steal or she'd content.
Let's roll the background color.
So background say Android color.
Darker gray.
OK.
Oh this looks good so far.
That's right an I.D. you say I.D. say bottom sheet OK on our bottom shoot load is ready.
So coming back to the main dot example O K let's use that bottom sheet load here.
So include Let's display the layout.
So which was more than cheap layout and we work to be done with allowed by moving on to the functionality
boy.
OK.
So let's create an instance of our bottom sheet level so private Linear Layout let's call it bottom
sheet layout.
OK let's initialize it.
So bottom sheet layout as a goal to find new by I.T. on I.T. bottom sheet.
Okay.
And we also need to create a bottom sheet behavior object.
So let's create dot.
So private bottom sheet behavior let's call it behavior.
So coming down.
So what behavior is it will do.
Well then she had behavior from let's watch some bottom she to some bottom sheet left.
Okay.
And we can define some callbacks so let's do that.
So behavior that set bottom she'd go box.
We're good to go.
So let's run an obligation and see
well obligations running.
So let's have a look.
Okay let's drag this up on a bottom sheet as of.
It's in the full screen so let's check out our bottom sheet labeled an example.
And as you can see the high is much better.
So let's change that to up content.
Let's run an application again and have a look.
Well applications running so let's check it out.
Let's drag it up.
And as you can see we've got a bottom sheet here so coming back door jar file you must be wondering.
We implemented this bottom sheet call log but we didn't use it.
So we'll do already about that later.
So right now I'll just show you what this onstage changed what all we can do.
So let's just create a switch on new state.
Let's define a case.
So bottom sheet behavior dot state globs.
So let's generate a toast here so toast.
Don't make text.
Let's go in the context so an activity like this and let's generate a message.
So let that be sheet collapsed.
Let's throw out the duration.
So in short and let's call this show function.
OK.
That's a great cue.
Similarly let's try it for another state so which was so state expanded and let's write it expanded
let's run our application and see what it does.
Well applications running so let's check it out.
That's right.
This up shows should expanded.
Let's drag this down.
It shows she'd collapsed.
So you can perform any action here.
You can just listen to the state of your bottom sheet and perform actions accordingly.
So that's all the bottom sheets for today.
If you have any doubts so far anyways feel free to drop a comment and we'll go through it.
But I did get.