问题描述
我有PSD
,分辨率为1080X1920
,它包含一个Dot
分辨率为22X22
的图像.
I have PSD
, resolution of that is 1080X1920
, it contains a Dot
image whose resolution is 22X22
.
我已裁剪该图像并将其放入我的 res
文件夹中.
I have cropped that image and put it in my res
folder.
我的问题是 Android 怎么会知道图像是用于 1080X1920
屏幕的.它会在 small
屏幕上打开更大的图像,并在 2560x1440
分辨率下打开相同的图像.
My question is how would Android know that the image is for 1080X1920
screen. It would open the same image bigger in small
screen and smaller in 2560x1440
resolution.
除了为每个屏幕尺寸放置不同的图像来告诉 android 使用特定屏幕尺寸的图像和其他屏幕
推荐答案
直接使用https://romannurik.github.io/AndroidAssetStudio/
例如,两个设备都报告屏幕尺寸正常实际屏幕尺寸和纵横比可能略有不同手工测量时不同.同样,两个设备报告hdpi 的屏幕密度可能具有实际像素密度稍微不一样.Android 将这些差异抽象为应用程序,因此您可以提供为通用尺寸设计的 UI和密度,让系统处理任何最终调整必要的
您必须创建不同的尺寸、布局、图像和图标文件以支持所有设备.
You have to create different dimen , layout , images and icon files to support all devices.
屏幕密度的变化.
xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp
制作此布局文件,以便所有设备都相同.
根据设备提供填充、边距、字体和所有属性.
Give padding ,margin ,font and all properties as per devices.
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7" tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10" tablets (720dp wide and bigger)
对于布局 ,
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra-large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra-large in landscape orientation
对于图片
res/drawable-mdpi/graphic.png // bitmap for medium-density
res/drawable-hdpi/graphic.png // bitmap for high-density
res/drawable-xhdpi/graphic.png // bitmap for extra-high-density
res/drawable-xxhdpi/graphic.png // bitmap for extra-extra-high-density
对于图标
res/mipmap-mdpi/my_icon.png // launcher icon for medium-density
res/mipmap-hdpi/my_icon.png // launcher icon for high-density
res/mipmap-xhdpi/my_icon.png // launcher icon for extra-high-density
res/mipmap-xxhdpi/my_icon.png // launcher icon for extra-extra-high-density
res/mipmap-xxxhdpi/my_icon.png // launcher icon for extra-extra-extra-high-density
对于启动器图标
36x36 (0.75x) for low-density
48x48 (1.0x baseline) for medium-density
72x72 (1.5x) for high-density
96x96 (2.0x) for extra-high-density
180x180 (3.0x) for extra-extra-high-density
192x192 (4.0x) for extra-extra-extra-high-density (launcher icon only; see note above)
这篇关于所有屏幕设备的图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!