Android:缩放分辨率之间的图像偏移

发布于 2024-12-06 11:48:27 字数 249 浏览 1 评论 0原文

我有一个应用程序,在横向模式下,我将一堆小写字母 ImageView png 排列起来,这样它们就位于一条假想线上。问题是它们的高度不同,即“h”比“a”高。因此,我一直在为每个字母设置 android:layout_marginTop 属性(以像素为单位),以便将它们排列在 Galaxy Tab 上。这已经奏效了。

我的问题是,当我在里程碑上运行应用程序时,偏移量的缩放有点不稳定。看起来好像发生了某种扩展,这确实有效,但并不完美。有人知道我该如何解决这个问题吗?

I have an app where, in landscape, I line up a bunch of lowercase alphabet ImageView pngs so that they are sitting on an imaginary line. The problem is that they are of different heights i.e. an 'h' is taller than an 'a'. Thus I've been setting the android:layout_marginTop attribute for each letter, in pixels, to line them up on the Galaxy Tab. This has worked.

My problem is that when I go to run the app on a Milestone, the scaling of the offsets is a litttttle wonky. It looks like there's some sort of scaling happening, which is kind of working, but it's not perfect. Anyone have an idea how I could remedy this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心安伴我暖 2024-12-13 11:48:27

我认为尝试对每个字母和每个显示分辨率的偏移进行硬编码将是一个真正的痛苦,并且维护起来会更加痛苦。

一个简单的解决方案是使用 Photoshop(或 gimp)调整 png 文件的大小,使它们都具有完全相同的尺寸,并将 PNG 的新区域设置为透明。

I think that trying to hard code the offsets for each letter and each display resolution is going to be a real pain and will be even bigger pain to maintain.

An easy solution would be to use photoshop (or gimp) to resize the png files so they all have the exact same dimensions and set the new region of the PNG to be transparent.

ぃ双果 2024-12-13 11:48:27

我首先会问你为什么要这样做......似乎过于复杂。也就是说,您可以尝试仅测量 ImageView 的最大高度并使用它。例如,x、h 和 g 都具有相同的 x 高度(小写字母 x 的高度),但 h 具有上升部分,g 具有下降部分(分别高于和低于标准 x 高度) )。您可以创建在基线上对齐的所有字母,给它们相同的高度(x 高度 + 上升高度 + 下降高度),然后只需在假想线上对齐顶部、底部或中心对齐它们,这应该给你一个正确的对齐。

真的,如果您可以分享更多信息(也许是屏幕截图?),可能会有一个更优雅的解决方案。

I would first question why you're doing it this way...seems overly complicated. That said, you could try to just measure the maximum heigh for the ImageViews and use that. For example, x, h, and g all have the same x-height (the height of the lowercase letter x) but the h has an ascender, and the g has a descender (which go above and below the standard x-height respectively). You could create all the letters aligned on the baseline, give them all the same height (the x-height + the ascender height + the descender height) and then just align top, bottom, or center align them on the imaginary line, which should give you a proper alignment.

Really, if you can share a little more information (a screenshot maybe?) there's probably a much more elegant solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文