0

I have a layout where I have to take an ImageView, and position it somewhere relative to something in the background image. For instance, the ImageView would be of an item, and on the background image there would be a shelf, and I would need to position the ImageView such that the item looks like it is on the shelf. Another example would be of a frame in the background, and I would need to position the image so it looks like it is in the frame. This needs to account for scaling. I do not need it to work through rotation, as there are different layouts for portrait and landscape.

s73v3r
  • 1,751
  • 2
  • 22
  • 48

1 Answers1

0

One way would be to associate the relative position of these items with the background images themselves. For instance, the height of the position of the top of the table is at x% of the total height of the image. Then, when it scales, it's now at x% of the current height.

Rich
  • 36,270
  • 31
  • 115
  • 154
  • That could work. I would have to make sure these positions are the same for all different forms of the image (hdpi, mdpi, xhdpi, etc) – s73v3r Mar 12 '14 at 23:04
  • @s73v3r You can also supply these dimensions as float resources and add qualifiers to the res/value folder. For example res/value-hdpi/dimens.xml would contain float values that correspond to the hdpi image, etc. I've never used float resources, but this link shows how: http://stackoverflow.com/a/8780360/53501 – Rich Mar 12 '14 at 23:12