简体   繁体   English

android中不同屏幕尺寸的可绘制尺寸

[英]drawable sizes for different screen sizes in android

i have a problem in android development that bored me. 我在Android开发中遇到了一个让我烦恼的问题。 my problem is screen size and dealing with that. 我的问题是屏幕尺寸和处理。 specially i have some problems with images. 特别是我有一些图像问题。 for example i want to create a background image for my activity that i created in photoshop and my background image contains a "HELLO" word on it. 例如,我想为我在photoshop中创建的活动创建一个背景图像,我的背景图像中包含一个“HELLO”字样。 but when i put it on drawable-xhdpi folder, it seems blurry and its not sharp!! 但是当我把它放在drawable-xhdpi文件夹上时,它看起来很模糊而且不锋利!! my phone is a nexus 4 and according to Google documentation i create background image in 640 x 480 size. 我的手机是nexus 4,根据Google文档,我创建了640 x 480大小的背景图像。

when i create background image in 960 x 720 size it seems better but not perfect. 当我创建960 x 720尺寸的背景图像时,它似乎更好但不完美。 in this case my image file size is very high! 在这种情况下我的图像文件大小非常高!

but what is the standard way for this? 但这是什么标准方式? please help me to solve this problem for ever. 请帮我永远解决这个问题。 i read google documentation but its not solve my problem! 我阅读谷歌文档,但它没有解决我的问题! http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/practices/screens_support.html

You should usually avoid creating images for certain screen sizes to make them background, because there are thousands of different devices and you would have to create dozens of such images. 您通常应该避免为某些屏幕尺寸创建图像以使其成为背景,因为有数千种不同的设备,您将不得不创建数十个这样的图像。

The first thing you need to be aware of is screen density. 您需要注意的第一件事是屏幕密度。

Generally you create 3 to 5 images when not even looking at screen size: low (120 dpi), medium (160 dpi), high (240 dpi), extra high (320 dpi) and 2*extra high (480 dpi). 通常,您甚至不看屏幕尺寸时会创建3到5个图像:低(120 dpi),中(160 dpi),高(240 dpi),超高(320 dpi)和2 *超高(480 dpi)。 These go into drawable-Xdpi folders, where X is one of l, m, h, xh, xxh. 这些进入drawable-Xdpi文件夹,其中X是l,m,h,xh,xxh之一。

Next thing when you want to have bigger images on bigger screens (bigger phones, small and big tablets), you may want to put images to folders like drawable-sw600dp-Xdpi. 接下来当你想在更大的屏幕(更大的手机,小型和大型平板电脑)上拥有更大的图像时,你可能想要将图像放到像drawable-sw600dp-Xdpi这样的文件夹中。 This is not a case for your phone. 这不适用于您的手机。

Nexus 4 is a xhdpi 640x384 dp device, but you should not treat it differently than Samsung Galaxy S2 (hdpi 533x320 dp). Nexus 4是xhdpi 640x384 dp设备,但你不应该对待它与三星Galaxy S2(hdpi 533x320 dp)不同。

Create an image of smaller size for both phones and center it horizontally. 为两部手机创建较小尺寸的图像并将其水平居中。 Eg 320x100 px for mdpi, 480x150 px for hdpi and 640x200 px for xhdpi (your phone). 例如,对于mdpi为320x100像素,对于hdpi为480x150像素,对于xhdpi(您的手机)为640x200像素。

With 1600+ android models even after they are categorized in few Screen size and a few DPI's its very difficult to manage layouts.. i suggest that you just concentrate on designing layouts wrt to screen size and then create views as Resizeable Views to neglect density effects. 有1600多个Android机型,即使它们被分类为少数屏幕尺寸和一些DPI,它很难管理布局..我建议您只需专注于设计屏幕大小的布局 ,然后创建视图作为可调整视图忽略密度效果。

Once you have created your layouts Resize the Views .. You can create a Custom View or resize on its onMeasure(); 创建布局后调整视图大小。您可以在其onMeasure()上创建自定义视图或调整大小;

the screen resolution for Nexus is 1280x768 ( http://www.google.com/nexus/4/specs/ ), resize the image to this resolution. Nexus的屏幕分辨率为1280x768( http://www.google.com/nexus/4/specs/ ),将图片大小调整为此分辨率。 In especial consideration some images can't handle the resolution and the image became disproportionately. 特别是一些图像无法处理分辨率,图像也不成比例。

for interesting resolution calculator: http://members.ping.de/~sven/dpi.html 有趣的分辨率计算器: http//members.ping.de/~sven/dpi.html

This is problem of Android Fragmentation and you just cannot deal with it perfectly as there is a several hundreds different devices. 这是Android碎片问题,你无法完美处理它,因为有数百种不同的设备。 As colleague above wrote Nexus 4 has resolution -1280 x 768 so for sure res of image as equal as 960 x 720 is good choice. 正如上面的同事所写,Nexus 4的分辨率为-1280 x 768,因此确保图像等于960 x 720是不错的选择。 I'm even surprised that google suggest 640 x 480 for xhdpi, it's definitely too less. 我甚至对谷歌建议640 x 480的xhdpi感到惊讶,这肯定太少了。

So as I said you are not able to make perfect looking graphics for all existing devices. 正如我所说,你无法为所有现有设备制作完美外观的图形。 You should choose the most popular devices from every screen category(xhdpi,mdpi,ldpi ... etc) to cover the most important market share. 您应该从每个屏幕类别(xhdpi,mdpi,ldpi等)中选择最受欢迎的设备来覆盖最重要的市场份额。

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

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