1

Is there any way to set an ImageView's exact coordinates in a relative layout? I found things related to "absolute layout", but I am informed that it is deprecated? How can I set the position of children in a relative layout?

Thanks!

foobar5512
  • 2,470
  • 5
  • 36
  • 52

2 Answers2

0

You can specify the top/left padding/margin of the component and place it using that (assuming the component is positioned on the top left corner of the RelativeLayout).

Savvas Dalkitsis
  • 11,476
  • 16
  • 65
  • 104
0

Depending on what you want to do, there are some options:

  1. If you want absolute positioning from the edge, you can use the padding/margin from whichever edge you want after aligning it to that edge (as mentioned in another response).

  2. You can similarly add padding/margin if you would like to place it besides another view.

  3. You can do this programattically using setX and setY

  4. You can use translationX and translationY (or their programattic equivalants) if you want the edges aligned to another view with an offset.

Hope this helps...

Aviral
  • 1,141
  • 1
  • 10
  • 16