Android 上的屏幕尺寸和精确的元素放置
我在支持不同的屏幕尺寸方面遇到问题。我的应用程序具有不同的 mdpi (320x480)、hdpi (480x800) 或 ldpi (240x432) 绘图。我也有不同的小布局、正常不长布局、正常长布局。每个尺寸缩放或放置功能都是在 dp 中完成的。然而我的问题是我需要在屏幕上精确放置一个元素,以便它完美地适应背景。这里的一个例子是我下载并在作为背景一部分的框架内显示的图像。或者,我还在图像视图对象的顶部画了一个圆(使用drawArc),并且需要精确地放置它以适合该图像上的“黑洞”。因为位置取决于背景,所以我将元素放置在父边距中。正如我所写,我正在使用 dp 来实现这一点。但是,如果我将设置适合 320x480 3" 屏幕,然后更改为 3.1",则元素会稍微错位并且不适合背景。如果我有 480x800 3.5 英寸设备,但更改为 3.6 英寸,则效果相同 - 元素稍微错位,但这足以让设计看起来很糟糕。我能做什么呢?我确信必须有一种方法可以在任何屏幕尺寸上实现这一点 - 即游戏必须使用某种机制并且它们可以在任何屏幕尺寸上运行。有人可以帮忙吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论