所有屏幕设备的图像大小
Image size for all screen devices
我有 PSD
,它的分辨率是 1080X1920
,它包含一个 Dot
图像,其分辨率是 22X22
。
我已裁剪该图像并将其放入我的 res
文件夹中。
我的问题是 Android 如何知道该图像适用于 1080X1920
屏幕。它会在 small
屏幕和 2560x1440
分辨率下打开更大的相同图像。
除了为每个屏幕尺寸放置不同的图像来告诉 android 将图像用于特定屏幕尺寸和比例用于其他 screens
[=28 之外,还有其他方法吗? =]
将大图放入drawable文件夹。
直接使用https://romannurik.github.io/AndroidAssetStudio/
For example, two devices that both report a screen size of normal
might have actual screen sizes and aspect ratios that are slightly
different when measured by hand. Similarly, two devices that report a
screen density of hdpi might have real pixel densities that are
slightly different. Android makes these differences abstract to
applications, so you can provide UI designed for the generalized sizes
and densities and let the system handle any final adjustments as
necessary
您必须创建不同的维度、布局、图像和图标文件以支持所有设备。
屏幕密度变化。
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
制作此布局文件,以便所有设备都相同。
根据设备提供填充、边距、字体和所有属性。
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)
结帐 Dimension 和
Supporting Multiple Screens 官方文档。
Android Studio 在您的 Android 工作室中安装了一个名为 "Batch Drawable" 的插件。这有助于创建不同大小的图像。
导入步骤:
文件-->设置-->插件-->浏览存储库-->点击安装按钮。
重新启动您的Android工作室,然后您将能够在Android工作室的文件菜单中找到"Batch Drawable"。
Link: https://github.com/winterDroid/android-drawable-importer-intellij-plugin
您无需再做任何操作,只需将不同分辨率的文件放入不同的drawable-xxx文件即可。请记住,所有图片必须具有相同的名称,但 Android 不会自动匹配每张图片的屏幕尺寸,因为文件名不匹配。祝你好运!
我有 PSD
,它的分辨率是 1080X1920
,它包含一个 Dot
图像,其分辨率是 22X22
。
我已裁剪该图像并将其放入我的 res
文件夹中。
我的问题是 Android 如何知道该图像适用于 1080X1920
屏幕。它会在 small
屏幕和 2560x1440
分辨率下打开更大的相同图像。
除了为每个屏幕尺寸放置不同的图像来告诉 android 将图像用于特定屏幕尺寸和比例用于其他 screens
[=28 之外,还有其他方法吗? =]
将大图放入drawable文件夹。
直接使用https://romannurik.github.io/AndroidAssetStudio/
For example, two devices that both report a screen size of normal might have actual screen sizes and aspect ratios that are slightly different when measured by hand. Similarly, two devices that report a screen density of hdpi might have real pixel densities that are slightly different. Android makes these differences abstract to applications, so you can provide UI designed for the generalized sizes and densities and let the system handle any final adjustments as necessary
您必须创建不同的维度、布局、图像和图标文件以支持所有设备。
屏幕密度变化。
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
制作此布局文件,以便所有设备都相同。
根据设备提供填充、边距、字体和所有属性。
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)
结帐 Dimension 和 Supporting Multiple Screens 官方文档。
Android Studio 在您的 Android 工作室中安装了一个名为 "Batch Drawable" 的插件。这有助于创建不同大小的图像。
导入步骤: 文件-->设置-->插件-->浏览存储库-->点击安装按钮。
重新启动您的Android工作室,然后您将能够在Android工作室的文件菜单中找到"Batch Drawable"。
Link: https://github.com/winterDroid/android-drawable-importer-intellij-plugin
您无需再做任何操作,只需将不同分辨率的文件放入不同的drawable-xxx文件即可。请记住,所有图片必须具有相同的名称,但 Android 不会自动匹配每张图片的屏幕尺寸,因为文件名不匹配。祝你好运!