android – 将图像缩放到从手机拍摄的不同可绘制文件夹中,以用作标题图像

Android Studio 1.3

你好,

我从Nexus 5手机上拍了一些照片.我想使用一个作为加载到imageview的标题.

但是,我不确定缩放和drawable-xhdi,drawable-xxhdi等,它应该进入.

我目前的图片是:

Width: 3200 pixels
Height: 2368 pixels
Size: 2.4 MB
file type: jpg

我有gimp照片编辑工具,我可以压缩成一个png文件来减小大小.但我不知道如何才能让图片在其他屏幕密度上看起来更好看.我必须将哪个可绘制文件夹放入?

非常感谢任何建议,

解决方法

首先,你应该知道有一个 limit on image size

OpenGl maximum size is 2048×2048 or else it throws an error: Bitmap too large to be uploaded into texture.

第二,你必须考虑,你的目标是什么设备.
android中有不同的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)

第3看Android Dashboard.

快速浏览显示,少数ldpi和几乎没有xxxhdpi设备.这是什么意思?您不需要为这些文件夹提供资源.但随心所欲.

Note: You do not need to provide xxxhdpi assets for all your app’s images.

4查看您的应用程序并找出最大尺寸:

因此,如果您的图片将成为标题,我认为它将匹配match_parent – >比方说,您正在设计您的应用程序以处理屏幕分辨率1920 * 1080(h * W)和更低.现在你看到第一个重要的步骤.如果您的图像match_parent和父级最大1080px宽,则不需要3200像素的宽图像!

5使用某些工具(如9-Patch-ResizerAndroid Asset Studio)调整图像大小,然后将其添加到可绘制文件夹中

6,在设备上测试并检查图像质量是否足够好.在平板电脑上,您可以考虑使用drawable-large和drawable-xlarge文件夹.

  • 320dp: a typical phone screen (240×320 ldpi,320×480 mdpi,480×800 hdpi,etc).
  • 480dp: a tweener tablet like the Streak (480×800 mdpi).
  • 600dp: a 7” tablet (600×1024 mdpi).
  • 720dp: a 10” tablet (720×1280 mdpi,800×1280 mdpi,etc).

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...