setX(), setTranslationX(), setY(), and setTranslationY()

后端 未结 3 1732
面向向阳花
面向向阳花 2021-02-05 05:50

What are the differences between setX(), setY(), and setTranslationX(), setTranslationY()? Are they setting offsets on existing coordinates or setting absolute positions?

3条回答
  •  日久生厌
    2021-02-05 06:15

    Setting X and Y sets the position of the view relative to the parent view's top left corner (not the absolute position on the screen). Setting the translation moves the view relative to where the parent laid it out. (The parent laid the view out at (left, top).)

    enter image description here

提交回复
热议问题