设置可绘制文件夹用于不同分辨率 [英] Setting drawable folder to use for different resolutions

查看:168
本文介绍了设置可绘制文件夹用于不同分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有4个不同大小的每一个,我需要在我的应用程序使用的图标。问题是,我的Nexus 7(1280×800)和GALAXY S2(800×480),似乎使用资源的绘制,华电国际。如何强制Nexus的使用资源,绘制,xhdpi,然后在10英寸的标签使用可绘制-xxhdpi。

我已经在我的清单文件

 <支持屏安卓调整大小=真
              机器人:smallScreens =真
              机器人:normalScreens =真
              机器人:largeScreens =真
              机器人:xlargeScreens =真
              机器人:anyDensity =真/>
 

解决方案
  

如何强制Nexus的使用资源,绘制-xhdpi然后   10英寸的标签使用可绘制-xxhdpi?

您不能。

在预选赛华电国际,xhdpi,xxhdpi 描述设备,屏幕不是大小的屏幕像素密度。 从官方文档

  

屏幕像素密度

     

屏幕的物理区域内的像素的量;平时   称为分辨率(每英寸点数)。例如,一个低密度   屏幕具有给定的物理区域内较少的像素相比,一个   正常或高的密度显示屏。为简单起见,Android的组的所有   实际的屏幕密度分为四个广义密度:低,中,   高和超高。

如果你想支持平板电脑也使用大,XLARGE 预选赛。的Nexus 7是一个大华电国际平板电脑(在技术上它是 tvdpi ,但获取图像华电国际)。所以,如果你想要把图像的Nexus 7,使名为绘制-大华电国际文件夹,并把图像那里。

注意:这是Nexus的7的特殊情况,因为即使的Nexus 7是一款7英寸的平板电脑,它具有分辨率 1280 * 800 。所以这是一个华电国际设备。但是,正常的7英寸设备具有较低分辨率的 1024 * 600 。因此,他们是 MDPI 设备。因此,绘制限定词可以改变。 (从我自己的经验,先放一个文件夹绘制-大MDPI 7英寸设备,并检查它的Nexus 7,如果有图像没问题,你没有把另一个文件夹,因为如果一个特定的文件夹不是present,Android将检查与最近的文件夹,并优化它的设备屏幕)

现在对于10英寸的平板电脑的情况下,他们是 XLARGE 设备和它们的密度可以从 MDPI 更改为 xhdpi (的Nexus 10)。但是,许多有 1280 * 800 ,他们是 MDPI 设备解决方案。

更好的做法是把下面的可绘制

  //手机
绘制,LDPI
绘制,MDPI
绘制,华电国际

//为7英寸平板电脑
绘制-大MDPI
绘制-大华电国际(适用于Nexus 7保护)

//为10英寸的平板电脑
绘制-XLARGE,MDPI
 

I have 4 different sizes for each of the icons I need to use in my app. The problem is My Nexus 7 (1280 x 800) and galaxy s2 (800 x 480) seem to use the resources in drawable-hdpi. How do I force the Nexus to use resources in drawable-xhdpi and then the 10 inch tab to use drawable-xxhdpi.

I have this in my manifest file

<supports-screens android:resizeable="true"
              android:smallScreens="true"
              android:normalScreens="true"
              android:largeScreens="true"
              android:xlargeScreens="true"
              android:anyDensity="true" />

解决方案

How do I force the Nexus to use resources in drawable-xhdpi and then the 10 inch tab to use drawable-xxhdpi?

You can't.

The qualifiers hdpi,xhdpi,xxhdpi describes the screen density of the device, not the size of screen. From the official doc

Screen density

The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen. For simplicity, Android groups all actual screen densities into four generalized densities: low, medium, high, and extra high.

If you want to support tablets also, use large, xlarge qualifiers. Nexus 7 is a large-hdpi tablet(technically it's tvdpi, but takes images from hdpi). So if you want to put images for Nexus 7, make a folder named drawable-large-hdpi and put the images there.

Note: This is the special case for Nexus 7. Because even though Nexus 7 is a 7 inch tablet, it has resolution of 1280 * 800. So it's an hdpi device. But normal 7 inch devices have lower resolutions of 1024 * 600. So they are mdpi devices. So the drawable qualifier can change. (From my own experience, first put a folder drawable-large-mdpi for 7 inch devices and check it on Nexus 7. If there is no problem with images, you dont have to put another folder. Because if a particular folder is not present, Android will check for the nearest possible folder and optimize it for the device screen)

Now regarding the 10 inch tablets case, they are xlarge devices and their densities can change from mdpi to xhdpi(Nexus 10). But many have resolution of 1280 * 800 and they are mdpi devices.

The better practice is to put the following drawables

// for Phones
drawable-ldpi
drawable-mdpi
drawable-hdpi

//for 7 inch tablets
drawable-large-mdpi
drawable-large-hdpi(for Nexus 7)

// for 10 inch tablets
drawable-xlarge-mdpi

这篇关于设置可绘制文件夹用于不同分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆