-2

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?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
a14
  • 31
  • 15

3 Answers3

1

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"
Mrunalraj Redij
  • 317
  • 2
  • 4
0

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)
Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
-1

Use the value (x, HEIGHT - y).

shx2
  • 61,779
  • 13
  • 130
  • 153
Amila
  • 5,195
  • 1
  • 27
  • 46