-3

I want to use absolute positioning in such a way that each object in the layout is in about the same position on each device. Is there maybe a library or a formula or something else I can use to achieve this?

silverAndroid
  • 960
  • 3
  • 11
  • 29
  • That's simply not possible. Devices have different screen-sizes, resolutions, etc. That is exactly why Android has a flexible layout framework. – 323go Mar 25 '15 at 15:14

2 Answers2

1

You certainly are aware that it's not a very good idea (because you'll have difficulties to adapt to different screen sizes/orientation), however, you may achieve this with FrameLayout and paddings

<FrameLayout ...>
    <View
       android:layout_paddingLeft="20dip"
       android:layout_paddingTop="10dip"
       ... />
</FrameLayout>
Orabîg
  • 11,718
  • 6
  • 38
  • 58
  • The thing is I don't want to use the XML layout because the positions of my objects are dynamic – silverAndroid Mar 25 '15 at 14:41
  • 1
    Well, in that case, you should : 1- Tell it in you SO question. 2- Change the layout parameters programmatically (use ```FrameLayout.LayoutParams```) – Orabîg Mar 25 '15 at 14:47
  • This is definitely not ideal, but why was `padding` mentioned insteag of `margin`? – Lamorak Mar 25 '15 at 22:59
  • Yes, you're right. Depending on which you choose, you can pick one or the other. There is a very useful visual representation of both solutions there : http://stackoverflow.com/questions/4619899/difference-between-a-views-padding-and-margin – Orabîg Mar 30 '15 at 14:57
-1

Use <AbsoluteLayout ></AbsoluteLayout>

hope it will work..

Avishek Das
  • 661
  • 1
  • 6
  • 20