如何为Android选择正确的图像分辨率
我已经为此奋斗了几天。我正在尝试编写一个小的自定义评级栏。带有一些自定义图像。当我检查 HTC Desire 上的图像时,图像看起来非常锯齿。我尝试过使用不同的分辨率和不同的尺寸,但仍然无法弄清楚什么分辨率/如何创建良好的质量。
我已经阅读了 android 网站上的指南,但无济于事。我认为我遇到的问题是在较高 dpi 的显示器上显示较低分辨率的图像。因此系统会放大图像。但我不知道如何解决这个问题。更高分辨率的图像?更大的图像?
任何建议都会很棒。
亚历克斯
I have been battling with this for a couple of days. I am trying to write a small custom rating bar. With some custom images. When I check the image I have on my HTC Desire, the image looks horribly aliased. I have tried using different resolutions and different sizes and still can't figure out what resolution/how to create a good quality.
I have read the guidelines on the android site but, to no avail. I think the problem I am having is displaying lower resolution images on a higher dpi display. So the system upscales the image. But I am not sure how to fix that. Higher resolution images? Larger images?
Any advice would be great.
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
之所以要做到这一点有点困难,是因为 Android 设备的屏幕分辨率和密度多种多样。幸运的是,Android SDK 在这方面有相当广泛的支持。 Android 开发指南的本节是一个很好的开始。
基本上,您需要了解密度无关像素(dp)的概念并使用诸如
DisplayMetrics
计算实际屏幕像素。是的,显然您需要更大、更高分辨率的图像来实现更高密度的屏幕。The reason why this is a bit of a challenge to get right is the wide variety of screen-resolutions and -densities of Android devices. Fortunately the Android SDK has pretty extensive support in this department. A very good start is this section of the Android Dev Guide.
Basically you need to understand the concept of Density-independent pixels (dp) and use classes like
DisplayMetrics
to calculate actual screen pixels. And yes, obviously you'll need larger, higher resolution images for higher density screens.