简体   繁体   English

如何使用不同的密度(mdpi、hdpi、xhdpi、...)

[英]How to use the different densities (mdpi, hdpi, xhdpi, …)

I see a lot of post on this topic, however I haven't seen an explanation on what image size to take as a reference, let me explain.我看到很多关于这个主题的帖子,但是我还没有看到关于以什么图像大小作为参考的解释,让我解释一下。

I want to add a background image and make it suitable for each phone screen size so from mdpi to xxhdpi (if I'm not talking nonsense)我想添加背景图像并使其适合每个手机屏幕尺寸,从 mdpi 到 xxhdpi(如果我不是在胡说八道的话)

What size should my base image be?我的基本图像应该是什么尺寸?

I used a 600x1200 image and a 1080x1920 then converts using this site我使用了 600x1200 图像和 1080x1920 然后使用此站点进行转换

https://romannurik.github.io/AndroidAssetStudio/ https://romannurik.github.io/AndroidAssetStudio/

Unfortunately I noticed that on my two phones the image was distorted, I'm starting to think my base image size was wrong不幸的是,我注意到我的两部手机上的图像失真了,我开始认为我的基本图像尺寸是错误的

So my question所以我的问题

What image size should I take to then create multiple densities?我应该采用什么图像尺寸来创建多个密度?

Sorry if it's redundant !!!如有多余请见谅!!!

I'm starting to learn how to adapt and it's not that easy我开始学习如何适应这并不容易

I think the site is for (mainly launcher) icons.我认为该网站用于(主要是启动器)图标。

If your target device's display has 1080x1920 size with xxhdpi (3x) density, just put an image of the size in the res/drawables/xxhdpi folder.如果您的目标设备的显示器具有 1080x1920 尺寸和 xxhdpi (3x) 密度,只需将尺寸的图像放在 res/drawables/xxhdpi 文件夹中。 No other densities are needed to be prepared.无需准备其他密度。 They will be re-scaled from the xxhdpi image if needed.如果需要,它们将从 xxhdpi 图像重新缩放。

If you still want to prepare for those densities, first prepare the highest density.如果你还想为那些密度做准备,首先要准备最高的密度。 If you want to use xxxhdpi (4x), you should start with xxxhdpi sized image.如果你想使用 xxxhdpi (4x),你应该从 xxxhdpi 大小的图像开始。 Then scale it down to xxhdpi (3x), xhdpi (2x), hdpi (1.5x) and mdpi (1x).然后将其缩小为 xxhdpi (3x)、xhdpi (2x)、hdpi (1.5x) 和 mdpi (1x)。

  1. xxxhdpi (4x): 100% xxxhdpi (4x): 100%
  2. xxhdpi (3x): 75% xxhdpi (3x): 75%
  3. xhdpi (2x): 50% xhdpi (2x): 50%
  4. hdpi (1.5x): 37.5% hdpi (1.5x): 37.5%
  5. mdpi (1x): 25% mdpi (1x):25%

Support different pixel densities: Provide alternative bitmaps 支持不同的像素密度:提供替代位图

If you want to create a background picture, your reference size is mdpi with 320x480px.如果要创建背景图片,您的参考尺寸是 mdpi 和 320x480px。 You can then calculate the size according to the factor然后您可以根据因子计算大小

  • hdpi: 1.5 (480x720) hdpi: 1.5 (480x720)
  • xhdpi: 2.0 (640x960) xhdpi: 2.0 (640x960)
  • xxhdpi: 3.0 (960x1440) xxhdpi: 3.0 (960x1440)
  • xxxhdpi: 4.0 (1280x1920) xxxhdpi: 4.0 (1280x1920)

Note however, that nowadays devices have all kinds of other aspect ratios (mostly longer).但是请注意,如今的设备具有各种其他纵横比(大多更长)。 So you have to design your background in a way, that the outer area does not contain important content.所以你必须以某种方式设计你的背景,使外部区域不包含重要内容。 Then use ScaleType CENTER_CROP and your image should not be distorted ( https://developer.android.com/reference/android/widget/ImageView.ScaleType )然后使用ScaleType CENTER_CROP并且您的图像不应失真( https://developer.android.com/reference/android/widget/ImageView.ScaleType

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Android中使用9种补丁图像以不同的2密度(如mdpi,ldpi,hdpi)? - How to use 9 patch images in android for different-2 densities(like mdpi,ldpi,hdpi).? 适用于MDPI,HDPI,XHDPI和XXHDPI的不同APK - Different APK for MDPI, HDPI, XHDPI and XXHDPI mdpi,hdpi,xhdpi文件夹的工作原理如何? - How mdpi, hdpi, xhdpi folder works? 如何在 mdpi、ldpi、hdpi、xhdpi 中调整图像大小 - How to resize image in mdpi, ldpi, hdpi, xhdpi 如何使用 drawable 兼容所有屏幕尺寸(idpi、mdpi、hdpi、xhdpi、xxhdpi) - how to use drawable to compatible with all screen sizes (idpi, mdpi, hdpi, xhdpi, xxhdpi) 使用9个Patch图像而不是mdpi / ldpi / hdpi / xhdpi图像 - Use 9 Patch images instead of mdpi/ldpi/hdpi/xhdpi images 如何在Android资产文件夹中保留hdpi,mdpi,ldpi和xhdpi文件? - How to keep hdpi,mdpi,ldpi and xhdpi files in the Android asset folder? android mdpi,hdpi,xhdpi,xxhdpi之间的关系如何计算 - android relationship between mdpi, hdpi, xhdpi, xxhdpi how to calculate 有没有办法创建一个图像(而不是4具有不同的分辨率ldpi,mdpi,hdpi和xhdpi)并用于所有的Android设备分辨率? - Is there any way to create one image(Instead of 4 with different resolutions ldpi,mdpi,hdpi and xhdpi) and use for all the android device resolutions? 缩放ldpi,mdpi,hdpi和xhdpi的图像 - scale images for ldpi mdpi hdpi and xhdpi
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM