I would like to find out how can I convert touch coordinate that I get in float form to an integer. I am pretty new to java programming and android. I want to define a rectangle around my touch area and then use something like this:
Rect touchArea = new Rect(); //I have only float coordinates to define this rect
Rect predefinedRect = new Rect(); //This rect is defined with integers
if(touchArea.intersect(predefinedRect)){
//do something
}
Also there isn’t method like Rect(RecF), at least I haven’t found one. So what could I do to use that .intersect() method?
There is a RectF constructor that takes a Rect. So you could use that and then use the intersect in the RectF class.
If you want to convert float to int you could just do
but be careful with how the float just gets cut and not rounded.