Screen sizes and precise element placement on Andr

2019-08-06 19:16发布

I have a problem with supporting different screen sizes. My application has different drawables for mdpi (320x480), hdpi (480x800) or ldpi (240x432). I also have different layout for small, normal-notlong, normal-long. Every size scaling or placement features are done in dp. However my problem is that I need to precisely place an element on the screen so it will perfectly fit to the background. One example here is an image that I download and show inside a frame that is part of the background. Or I also draw a circle (using drawArc) on the top of an imageview object and need to place it precisely to fit a 'black hole' that is on that image. Because the position is dependent on the background I place the elements with parent margins. As I wrote I am using dp for that. However If I fit my setting for a 320x480 3" screen and then change to 3.1" the elements are slightly misplaced and don't fit the background. The same if I have 480x800 3.5" device but change to 3.6" - the elements are misplaced slightly but that is enaught to look poorly in the design. What can I do about it? I am sure there has to be a way to achieve this on any screen size - i.e. games must use some kind of that mechanism and they work on any screen size. Can any one help?

0条回答
登录 后发表回答