The next thing that I would like to implement is the functionality to change the brush size, because
we can literalness to add the colors.
And first of all, I would like to take care of the thickness of our brush.
And in order to do that, what we need to do is we go to our drawing view and here I'm going to create
a new function.
So here at the bottom, I'm going to create a function called set size for brush.
And as you can see, I'm not adding the private visibility modifier there.
And so what I'm going to need is the new size, which is of like float.
Now, of course, I could go ahead and just say that the AMBRISH size should be whatever float value
I get.
But I actually need to make that look the same on different screen sizes because for example, 20 pixels
on one screen look very different than 20 pixels on another screen.
So for example, the bigger screen will have with the same amount of pixels, have a bigger prush.
So that's something that I don't want to calculate manually.
I want it to be done by.
Myself, my tool here as well, so I can use something called typed value, and this class has.
The method applied I mentioned.
So now let's look at the plot I mentioned to understand this a little better.
So convert's and unpack complex data value, holding a dimension to fit its final floating point to
value the two parameters, unit and value are as in lake type dimensions.
So we can check that out.
But what's more interesting is what happens here.
So unit is the unit to convert from value the value to apply the unit to and matrix the current display
metrics to use in the conversion supplies to display density and scaling information.
So that's what I was talking about.
The application is going to know what screen size it's playing on and then depending on that, it will
adjust the size of our process.
So that's the idea behind the approach that I'm taking here.
So as a type, the value that.
Complex Unit DEPI, it's going to be the unit that I'm going to use, then the value that I want to
pass is the new size, so.
Let's look at it again, the second failure here was the failure to apply the units to and then finally,
the metrics that I want to use here are coming from resources, dot display metrics.
So resources.
Returns the resources associated with this view.
And then what we get is the display metrics.
And this pemetrexed return to current display metrics that are in effect for this resource object,
the returned object should be treated as read-only.
OK, so this just means that it will give us the current display metrics.
So how many pixels it has and so forth.
All right.
So that's the whole idea behind.
Using this approach, and then we can go ahead and use this display metrics or our new breast size as
the stroke of our draw paint.
So draw paint.
Stroke with should be our airbrush size.
So now, of course, we can go ahead and use this set size or brush in our main activity, so let's
go to our main activity.
And set to process here, so drawing view.
That said, size four brush, twenty two float.
So what that will do is it will take 20, which was our default value here, which we set as to value.
At this point here.
So to be super precise, you could, of course, go ahead and comment this line out or even delete it
because you're not going to required it anymore, because we are setting it here.
But that could be a little too late, so.
Well, actually, it doesn't matter because we set it to zero here as well, so at that point you can
get rid of this line of code here if you really want to save every single possible line.
So let's test this, even though we will really not see any difference.
But we can still see if it's going to be 20, actually, because we originally set it to zero.
Only the main activity thought Katie, we change it again to 20.
So if we can draw anything now, then we know that it's working.
And as you can see, it's working.
Even though now 20 looks very different, it's a lot thicker.
OK, so this 20 is a lot thicker than a 20 that we had before where we just said it to be 20 to float.
But now it's taking into consideration the dimension of our screen as well.
All right, and this is an important preparation for the next video where we are going to add the functionality
to swap sizes of our brush.
All right.
So where we're going to have the different buttons to choose from.
So see you in the next video.