简体   繁体   English

Android:支持所有设备的背景图像大小(以像素为单位)

[英]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: 例如:

  • xhdpi: 720x1280 px xhdpi:720x1280像素
  • hdpi: 480x800 px hdpi:480x800像素
  • mdpi: 320x480 px mdpi:320x480像素
  • ldpi: 240x320 px ldpi:240x320像素

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/

Check this. 检查一下。 This image will show for all icon size for different screen sizes 此图像将针对不同屏幕尺寸显示所有图标大小

尺寸

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: 跟着这些步骤:

  1. Open the existing image in GIMP tool. 在GIMP工具中打开现有图像。
  2. Go to "Image" menu, and select "Scale Image..." 转到“图像”菜单,然后选择“缩放图像...”
  3. 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像素

  4. 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: 所以我要做的是:

  • Keep to the 3:4:6:8:12:16 scaling ratio between the six generalized densities (ldpi, mdpi, hdpi, etc). 保持6个广义密度(ldpi,mdpi,hdpi等)之间的3:4:6:8:12:16比例。
  • You should not include xxxhdpi elements for your UI elements, this resolution is meant for upscaling launcher icons only (so mipmap folder only) ... You should not use the xxxhdpi qualifier for UI elements other than the launcher icon. 您不应该为UI元素包含xxxhdpi元素,此分辨率仅用于升级启动器图标(仅限mipmap文件夹)... 您不应将xxxhdpi限定符用于启动器图标以外的UI元素。 ... although eg. ...... 虽然例如。 on the Samsung edge 7 calling getDisplayMetrics().density returns 4 (xxxhdpi), so perhaps this info is outdated. 在三星边缘7调用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。

  • I could also acknowledge that downsampling is generally an easy way to scale and thus I might want slightly oversized bitmaps bundled in my apk (Note: higher memory consumption). 我还可以承认,下采样通常是一种简单的扩展方式,因此我可能需要在我的apk中捆绑稍微过大的位图(注意:更高的内存消耗)。 Once more assuming that the width and height of the pixel screen is represetative, I would scale up the 1080x1920 by a factor of 480/441, leaving my maximum resolution background image at approx. 再一次假设像素屏幕的宽度和高度是具有代表性的,我会将1080x1920的比例放大480/441倍,使我的最大分辨率背景图像保持在大约。 1200x2100, which should then be scaled by the 3:4:6:8:12. 1200x2100,然后按3:4:6:8:12缩放。
  • Remember, you only need to provide density-specific drawables for bitmap files (.png, .jpg, or .gif) and Nine-Patch files (.9.png). 请记住,您只需要为位图文件(.png,.jpg或.gif)和Nine-Patch文件(.9.png)提供特定于密度的drawable。 If you use XML files to define drawable resources (eg. shapes), just put one copy in the default drawable directory. 如果您使用XML文件来定义可绘制资源(例如形状),只需将一个副本放在默认的drawable目录中。
  • If you ever have to accomodate really large or odd aspect ratios, create specific folders for these as well, using the flags for this, eg. 如果您必须容纳非常大或者奇数的宽高比,也可以使用这些标志创建特定的文件夹,例如。 sw , long , large , etc. swlonglarge
  • And no need to draw the background twice. 而且无需绘制两次背景。 Therefore set a style with <item name="android:windowBackground">@null</item> 因此,使用<item name="android:windowBackground">@null</item>设置样式

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM