Search code examples
androidposition

Android | SetY and SetX values


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.


Solution

  • 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.