Change coordinates to bottom left corner

2.4k Views Asked by At

How can I change coordinates to bottom left corner?

I know that's in Java the coordinates begin from Top=Left corner, but I'm asking if can someone help me how can I change it to begin (0,0) coordinates from Bottom-Left corner?

3

There are 3 best solutions below

0
On BEST ANSWER

getHeight() will get you the size height. so (0, getHeight()) will give you the left-bottom point. But take into consideration the height of the object you want to place. So you may want to use

(0, getHeight() - heightOfObject)
0
On

Use the value (x, HEIGHT - y).

0
On

I think it's too late, but for people like me (new to android development). The above answers are correct but here is a more detailed one

If you get the coordinate with respect to top left as (a,b), then the coordinates with respect to the bottom left are simply (a, h-b) where h is the height of the view.

Example:

float x = getXcoordinatesonTouch();
float y = getYcoordinatesonTouch();

//should return height
float h = getHeightoftheView();

float transformY = h - y;

//"x" should be as it is
//Now you can show "x" and "transformY"