[英]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)。
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
然后您可以根据因子计算大小
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.