[英]Android: Background Image Size (in Pixel) which Support All Devices
I am creating an Application which will run on all Android Devices. 我正在创建一个将在所有Android设备上运行的应用程序。 I want to create xhdpi Graphics for My App.
我想为我的应用程序创建xhdpi Graphics。 My App is full screen.
我的应用程序全屏。 I am confused in Creating graphics.
我对创建图形很困惑。 can any one tell me the best sizes of my background image in pixels.
谁能告诉我背景图像的最佳尺寸(以像素为单位)。
For Example: 例如:
Suggest me the best sizes which will appear on all devices good. 建议我在所有设备上出现的最佳尺寸。 Because my graphics are the core of my app.
因为我的图形是我的应用程序的核心。
I want that every device get the best image which it want. 我希望每台设备都能获得想要的最佳图像。 Android will be not involved in compressing or expanding of image.
Android将不参与压缩或扩展图像。
The following are the best dimensions for the app to run in all devices. 以下是应用在所有设备上运行的最佳维度。 For understanding multiple supporting screens you have to read http://developer.android.com/guide/practices/screens_support.html
要了解多个支持屏幕,您必须阅读http://developer.android.com/guide/practices/screens_support.html
xxxhdpi: 1280x1920 px
xxhdpi: 960x1600 px
xhdpi: 640x960 px
hdpi: 480x800 px
mdpi: 320x480 px
ldpi: 240x320 px
Android Devices Matrices Android设备矩阵
ldpi mdpi hdpi xhdpi xxhdpi xxxhdpi
Launcher And Home 36*36 48*48 72*72 96*96 144*144 192*192
Toolbar And Tab 24*24 32*32 48*48 64*64 96*96 128*128
Notification 18*18 24*24 36*36 48*48 72*72 96*96
Background 240*320 320*480 480*800 768*1280 1080 *1920 1440*2560
(For good approach minus Toolbar Size From total height of Background Screen and then Design Graphics of Screens ) (对于良好的方法减去工具栏大小从背景屏幕的总高度,然后屏幕的设计图形)
For More Help (This link includes tablets also): 如需更多帮助(此链接还包括平板电脑):
https://design.google.com/devices/ https://design.google.com/devices/
Android Native Icons (Recommended) You can change color of these icons programmatically . Android原生图标(推荐)您可以通过编程方式更改这些图标的颜色。 https://design.google.com/icons/
https://design.google.com/icons/
I looked around the internet for correct dimensions for these densities for square images, but couldn't find anything reliable. 我环顾互联网寻找方形图像的这些密度的正确尺寸,但找不到任何可靠的东西。
If it's any consolation, referring to Veerababu Medisetti's answer I used these dimensions for SQUARES :) 如果有任何安慰,请参考Veerababu Medisetti的答案,我将这些尺寸用于SQUARES :)
xxxhdpi: 1280x1280 px
xxhdpi: 960x960 px
xhdpi: 640x640 px
hdpi: 480x480 px
mdpi: 320x320 px
ldpi: 240x240 px
GIMP tool is exactly what you need to create the images for different pixel resolution devices. GIMP工具正是您为不同像素分辨率设备创建图像所需的工具。
Follow these steps: 跟着这些步骤:
Use below pixel dimension that you need: 使用您需要的像素尺寸:
xxxhdpi: 1280x1920 px xxxhdpi:1280x1920像素
xxhdpi: 960x1600 px xxhdpi:960x1600像素
xhdpi: 640x960 px xhdpi:640x960 px
hdpi: 480x800 px hdpi:480x800像素
mdpi: 320x480 px mdpi:320x480像素
ldpi: 240x320 px ldpi:240x320像素
Then "Export" the image from "File" menu. 然后从“文件”菜单中“导出”图像。
My understanding is that if you use a View
object (as supposed to eg. android:windowBackground
) Android will automatically scale your image to the correct size. 我的理解是,如果你使用一个
View
对象(假设例如android:windowBackground
),Android会自动将你的图像缩放到正确的大小。 The problem is that too much scaling can result in artifacts (both during up and down scaling) and blurring. 问题是过多的缩放会导致伪像(在向上和向下缩放期间)和模糊。 Due to various resolutions and aspects ratios on the market, it's impossible to create "perfect" fits for every screen, but you can do your best to make sure only a little bit of scaling has to be done, and thus mitigate the unwanted side effects.
由于市场上的各种分辨率和方面比率,不可能为每个屏幕创建“完美”适合,但您可以尽力确保只需要进行一些缩放,从而减轻不必要的副作用。 So what I would do is:
所以我要做的是:
getDisplayMetrics().density
returns 4 (xxxhdpi), so perhaps this info is outdated. getDisplayMetrics().density
返回4(xxxhdpi),所以这个信息可能已经过时了。 Then look at the new phone models on the market, and find the representative ones. 然后看看市场上的新手机型号,找到具有代表性的型号。 Assumming the new google pixel is a good representation of an android phone: It has a 1080 x 1920 resolution at 441 dpi, and a screen size of 4.4 x 2.5 inches .
假设新的谷歌像素是Android手机的一个很好的代表:它具有1080 x 1920分辨率,441 dpi,屏幕尺寸为4.4 x 2.5英寸 。 Then from the the android developer docs :
然后从android开发人员docs :
- ldpi (low) ~120dpi
ldpi(低)~120dpi
- mdpi (medium) ~160dpi
mdpi(中)~160dpi
- hdpi (high) ~240dpi
hdpi(高)~240dpi
- xhdpi (extra-high) ~320dpi
xhdpi(超高)~320dpi
- xxhdpi (extra-extra-high) ~480dpi
xxhdpi(extra-extra-high)~480dpi
- xxxhdpi (extra-extra-extra-high) ~640dpi
xxxhdpi(extra-extra-extra-high)~640dpi
This corresponds to an xxhdpi
screen. 这对应于
xxhdpi
屏幕。 From here I could scale these 1080 x 1920 down by the (3:4:6:8:12) ratios above. 从这里我可以按照上面的(3:4:6:8:12)比例缩放这些1080 x 1920。
sw
, long
, large
, etc. sw
, long
, large
等 <item name="android:windowBackground">@null</item>
<item name="android:windowBackground">@null</item>
设置样式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.