Android Studio 1.3
你好,
我用 Nexus 5 手机拍了一些照片。我想将一个用于作为加载到 ImageView 中的 header 。
但是,我不确定缩放以及应该放入哪个 drawable-xhdi、drawable-xxhdi 等。
我目前的图片是:
Width: 3200 pixels
Height: 2368 pixels
Size: 2.4 MB
file type: jpg
我有 gimp 照片编辑工具,我可以将它压缩成 png 文件以减小尺寸。但我不确定如何才能使图片在其他屏幕密度下看起来不错。我必须将每个可绘制文件夹放入哪个文件夹?
非常感谢您的任何建议,
最佳答案
1st 首先,你应该知道有一个 limit on image size :
OpenGl maximum size is 2048x2048 or else it throws an error: Bitmap too large to be uploaded into texture.
第二您必须考虑,您的目标设备是什么。 有不同的qualifiers在安卓中:
Screen size: Actual physical size, measured as the screen's diagonal. For simplicity, Android groups all actual screen sizes into four generalized sizes: small, normal, large, and extra-large.
Screen density The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen. For simplicity, Android groups all actual screen densities into six generalized densities: low, medium, high, extra-high, extra-extra-high, and extra-extra-extra-high.
- 小型 和正常尺寸 - 手机
- 大尺寸 - 7' 平板电脑(例如 sw600 - 最小宽度 600dp)
- xlarge 尺寸 - 10 英尺平板电脑(例如 sw720 - 最小宽度 720dp)
第三看Android Dashboard .
快速查看显示,很少有 ldpi 和几乎没有 xxxhdpi 设备。这是什么意思?您不需要为这些文件夹提供资源。但随心所欲。
Note: You do not need to provide xxxhdpi assets for all your app's images.
4th 查看您的应用程序并找出最大尺寸:
因此,如果您的图像将成为标题,我假设它将匹配父级 -> 假设您正在设计您的应用程序以在 1920*1080 (h*w) 及更低的屏幕分辨率上运行。现在你看到了第一个重要的步骤。 如果您的图像 matches_parent 和父图像的最大宽度为 1080 像素,则您不需要 3200 像素宽的图像!
5th 使用 9-Patch-Resizer 等工具调整图像大小或 Android Asset Studio并将其添加到您的可绘制文件夹
6th 在设备上测试它并检查图像质量是否足够好。在平板电脑上,您可能会考虑使用 drawable-large 和 drawable-xlarge 文件夹。
- 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
- 480dp: a tweener tablet like the Streak (480x800 mdpi).
- 600dp: a 7” tablet (600x1024 mdpi).
- 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
关于android - 将图像缩放到从我的手机中获取的不同可绘制文件夹以用作标题图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32152178/