Welcome back.
And this video, we're going to implement this functionality that you see here, so first of all, a
little green button with a calculator text underneath, and once I click on it, it will open up this
new activity called calculate BMI or at least BMI calculator or something like that.
I'm going to call this activity just BMI, because that's going to be descriptive enough for our purposes.
So let's get started.
Therefore, the first thing that I'm going to add are going to be a couple of UI elements here.
So what I will do is I'm going to keep it simple.
I'm just going to copy this frame layout that I had created already for our circle.
Here, you see, because it's basically the same thing that we want to achieve, right?
Want to have a circle with a text inside of it.
The circle should be smaller and the background should be different, but the same while the rest is
the same, basically.
So let's give this a different name.
Let's call this one f hell be am I?
And then accordingly, this text view may double check.
Well, let's leave it as it is actually and get rid of this constraint here and replace it with bottom
to bottom of parent.
And top tip, top of parents as well.
And then we can make changes once we need them.
So in our AFL BMI here, I want this to be underneath my AFL start.
OK, so top to bottom of a false start, then it should be bottom to bottom off.
The parent as well.
OK, so should drag towards the boy, the parent, I want to have a different background color, so
I'm just going to use my accent background, which I had created earlier, which is there's this circle,
right?
You recall it was this shape, just a green circle.
All right.
And now.
We just need to change its size, so I'm going to go with 70 density pixels for width and height.
In both directions and then to TextView inside of it will just display a different text, so it will
just display BMI.
OK.
And then I need another text view underneath this frame layout.
So if we look at it, this is the BMI that we're currently getting.
Our actually that might change the color of my.
BMI here as well.
So if this text for you, I want to use white as the color, OK, because I think brown or gray in green
doesn't look as good.
So now let's add another texture underneath here, and I'm just going to say that it should be underneath
the BMI frame lay out.
It will have the text of calculator.
We'll use the green color to ESP and we'll be bold.
And by the way, we could of course, use this button size text default setting here as well if we wanted
to.
OK, and now let's look at the design and could see we have this BMI plus the calculator texture underneath.
Now, once we click on this frame layout BMI, I want to start a new activity and I want to open this
activity that we're going to create.
Let me call it BMI activity.
And let's call this activity BMI.
This lay out activity on the score by.
And now what do we want to have inside of this activity, BMI?
Well, I just want to have the toolbar in there.
OK.
So let me go over to activity BMI and change it.
So for now, I'm going to use a relative layout in here.
We can change it later on if we need to.
But the relative layout will be fine.
The orientation should be vertical.
And so thing is this layout is empty for now, right?
The only thing that I want to have for now is going to be the toolbar and we will later see what we
want to do with it.
OK, so much parent.
And the height should be the height of an action bar.
OK, so here we need to use Android's colon 8r dart action bar size or slash action bar size, as we've
done before.
OK, and then I'm going to give it the white background.
Like so.
Now, let's just give it an ID.
So here I.D. will be toolbar on the score, BMI on the score activity.
OK.
So that's our activity, BMI looks as of now.
Let's see how the BMI activity will be set up, so here we need to use binding.
So let's set up the activity binding here activity BMI binding for it to be used.
So let's import it, then we need to set the binding object.
So you're binding, initialize it with activity binding, inflate layout and Fletcher, as we have done
before, then we need to set this to be the root of the binding.
So binding that route, you see many things, they really just repeat and repeat.
It's always the same when working with activities.
And then I want to use the action bar, OK?
And we have used action bar in the exercise activity, for example.
So here, let's just copy this entire part here.
There would be one minor change, however.
So set up action bar will be supported and will need to bind the action bar.
And therefore I will need to set support action bar like so use my binding object binding.
To toolbar EMI activity and see that.
Yeah, I forgot to copy this part of the year.
OK, so.
Now we need to set this stuff up and.
Our tool bar, how do we call it, we call it to be my activity.
And it should called on back pressed method.
OK, now what you can do is you can change the name of the or the title of the sport action bar, OK,
support action bar title is, for example, a property that you can overwrite and this is a Nullarbor.
So we need to add the question mark here, and I could just say something like calculate BMI.
And now let's see how this is gonna look like, so that shows you that you can overwrite properties
of your support action bar directly in your calling code so that we are okay.
Just so let's finish this.
Let's go over to the BMI calculator.
And of course, it doesn't happen yet.
Let me go over to the main activity and actually make it possible so that we can click on this BMI button.
What is internally, of course, not a real button, but instead is a frame layout.
So here, instead of using a failed start, I'm going to use BMI and the intent should move us to the
BMI activity.
And that's pretty much it, I believe.
So now let's run it again.
You see, I just copied my hold on, Cliff, listen there for the effort start, and now I should be
good.
So taking on it sends us over to the calculate BMI activity.
And now we can, of course, set up everything that we need in here, what we can then actually calculate
our BMI based on our size or height, better said and weight.
OK, so see you in the next video where we're going to prep the user interface for it.