2

So we have this two methods where we can change the (x,y) position of a view on the screen, but my question is what is their value set exacly?

Is it the position of the Top-Left corner of the view? the position of the center of the view? Bottom-Left corner?

Thanks.

user12597562891
  • 141
  • 1
  • 2
  • 7

1 Answers1

0

Method setX(float x) , here x is the position in pixel where you want to set this view. The point (0,0) is the Top-Left corner and your screen resolution weigth x height(i.e. 720x1080) is the bottom right corner. If you want to set view in middle then it'll be like view.setX(weidth/2) and view.setY(height/2). For detailed docs please read this.

Brijesh Kumar
  • 1,685
  • 2
  • 17
  • 28
  • 1
    Hey, i was more interested of knowing what point of the view does the setX and setY is changing? it's Top-Left / Top-Right / Bottom-Left / Bottom-Right ? – user12597562891 Oct 20 '16 at 07:12
  • sorry but I didn't get you. Please explain "point of the view" – Brijesh Kumar Oct 20 '16 at 07:21
  • 1
    Hey, what i mean is when you use setX and setY method, which part of the view will be set to that (x,y) ? the Top-Left? Top-Right? Bottom-Left? Bottom-Right? the center of the view? – user12597562891 Oct 20 '16 at 07:24
  • k. I get it. It's Top-Left of the view. And if you want to set it as centre of the view then it'll be like `view.setX(x+view.getWidth()/2)` – Brijesh Kumar Oct 20 '16 at 07:28
  • 1
    @brijesh kumar Rather `view.setX(x-view.getWidth()/2)`, your version would put the view even further to the right. – Firzen Nov 19 '19 at 10:45