简体   繁体   English

如何知道哪个手机支持哪种布局(hdpi,mdpi和xhpi)?

[英]how to know which phone support which layout(hdpi , mdpi and xhpi)?

I'm a little confused about how to determine which phones support what layout types. 我对如何确定哪些手机支持哪种布局类型感到困惑。 I've done some research but haven't found a satisfying answer. 我做了一些研究,但没有找到令人满意的答案。

For example, I've found the below guide: 例如,我找到了以下指南:

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

However, I still have some concerns: 但是,我仍有一些担忧:

  1. Samsung grand (480*800) and HTC wild fire S (320*480) both support MDPI. 三星宏伟(480 * 800)HTC野火S(320 * 480)都支持MDPI。 These screens have very different resolutions, yet have the same layout type? 这些屏幕具有非常不同的分辨率,但具有相同的布局类型?

  2. Galaxy note 2 (1280*720) support HDPI. Galaxy note 2(1280 * 720)支持HDPI。 If HD (720p) is only HDPI, when what device/resolution supports XHDPI? 如果HD(720p)只是HDPI,那么什么设备/分辨率支持XHDPI?

  3. I've already asked a related question here: How to set layout on 7" two different tablet? . 我已经在这里问了一个相关的问题: 如何在7“两种不同的平板电脑上设置布局?

  4. My most important question, however, is this: How do I know which devices or screen resolutions support each layout type? 然而,我最重要的问题是: 我如何知道哪种设备或屏幕分辨率支持每种布局类型?

Android treats mdpi (160 pixels/inch) as the base density . Android将mdpi(160像素/英寸)视为基本密度 So for mdpi devices , 1 dp = 1 pixel . 因此对于mdpi设备1 dp = 1像素 At higher densities, there are more pixels per inch (240 for hdpi, 320 for xhdpi). 在更高的密度下,每英寸有更多像素(hdpi为240,xhdpi为320)。

AutoMatic Scaling by Android itself: Android本身的AutoMatic Sc​​aling:

Android attempts to make graphic images occupy the same physical dimensions on the screen regardless of the device pixel density. 无论设备像素密度如何,Android都会尝试使图形图像在屏幕上占据相同的物理尺寸。 So if all it finds is an mdpi resource, and the device is hdpi, it will scale the graphic by 240/160 = 150%, and it will double the size of the graphic for xhdpi. 因此,如果它找到的只是mdpi资源,并且设备是hdpi,它将按240/160 = 150%缩放图形,并且它将使xhdpi的图形大小加倍。

Using different versions of graphics : 使用不同版本的图形:

If you don't want this automatic scaling (which can make graphics look poor), you can simply supply your own version of graphic resources for use at higher densities. 如果您不希望这种自动缩放(可能会使图形看起来很差),您可以简单地提供自己的图形资源版本,以便在更高的密度下使用。 These graphics should be of the same size that Android would scale an mdpi resource. 这些图形的大小应与Android扩展mdpi资源的大小相同。

Note : the pixels/inch that was stored in the image file has nothing to do with this. 注意:存储在图像文件中的像素/英寸与此无关。 It's all based on where you put the graphics files in the resources directory for your project. 这完全取决于您将图形文件放在项目的资源目录中的位置。 Any graphics placed in res/drawable are assumed to be properly sized for mdpi displays, as are graphics placed in res/drawable-mdpi. 假设放置在res / drawable中的任何图形都适合mdpi显示,而res / drawable-mdpi中的图形也是如此。 Image files that it finds in res/drawable-hdpi are assumed to be properly sized for hdpi displays, etc. When your program runs on a particular device, Android will first look for a graphic that matches the display density of that device. 它在res / drawable-hdpi中找到的图像文件被假定为适合hdpi显示等的大小。当您的程序在特定设备上运行时,Android将首先查找与该设备的显示密度相匹配的图形。 If it does not find one but instead finds one for a different density, it will use that and automatically scale the image based on the above rules. 如果找不到一个,而是找到一个不同的密度,它将使用它并根据上述规则自动缩放图像。

As the ldpi, mdpi and hdpi refer to screen density , which means how much pixels can fit into a single inch . 由于ldpi,mdpi和hdpi指的是屏幕密度 ,这意味着可以在一英寸内容多少像素

the ratio in pixels between them is: 它们之间的像素比例为:

ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3

so lets take an image with about the size of 100X100 : 所以我们拍摄大小为100X100图像

for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300

this way, for screens with the same size but different DPI, all the images seem the same size on screen. 这样,对于具有相同尺寸但不同DPI的屏幕,所有图像在屏幕上看起来都相同。

look into these details: android manages all this by itself, you just have to provide layouts and images in relative folders 看看这些细节:android自己管理所有这些,你只需要在相关文件夹中提供布局和图像

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
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/my_icon.png        // bitmap for medium density
res/drawable-hdpi/my_icon.png        // bitmap for high density
res/drawable-xhdpi/my_icon.png       // bitmap for extra high density

暂无
暂无

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

相关问题 ldpi、mdpi、hdpi 和 xhdpi 屏幕的背景应该是哪种尺寸? - Which size should a background be for ldpi, mdpi, hdpi and xhdpi screens? 我可以只提供一个可绘制文件夹,而不是4个(hdpi,ldpi,mdpi,xhpi) - Can i provide just one drawable folder instead of 4 (hdpi,ldpi,mdpi,xhpi) Drawable V21 vs V24 vs hdpi、mdpi、xhdpi 等自定义文件夹。 我应该将图像放在哪个文件夹中以支持多设备? - Drawable V21 vs V24 vs custom folders for hdpi,mdpi,xhdpi etc.. ? In which folder should I put my images for multi-device support? Android:限制apk文件仅安装在使用HDPI和MDPI图像的设备中。 - Android : Restrict apk file to install Only in Devices Which Uses HDPI & MDPI images. 我怎么知道我应该为不同的android res(hdpi,mdpi,ldpi)制作一张图片的大小? - how do i know how big i should make a picture for the different android res (hdpi,mdpi,ldpi)? Android资源 - 哪些分辨率应该进入hdpi,ldpi,mdpi和xhdpi目录 - Android Resources - which resolutions should go into the hdpi, ldpi, mdpi and xhdpi directories 如何知道Android在Android中使用320-hdpi或320-mdpi - How to know screen uses 320-hdpi or 320-mdpi in Android 如何使用不同的密度(mdpi、hdpi、xhdpi、...) - How to use the different densities (mdpi, hdpi, xhdpi, …) mdpi,hdpi,xhdpi文件夹的工作原理如何? - How mdpi, hdpi, xhdpi folder works? 如何在 mdpi、ldpi、hdpi、xhdpi 中调整图像大小 - How to resize image in mdpi, ldpi, hdpi, xhdpi
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM