使用Android应用的设计规模和比重,资源问题 [英] Use size and density-specific resources problems in Android app design

查看:192
本文介绍了使用Android应用的设计规模和比重,资源问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我读了关于支持多屏幕Android的教程。我有一些问题在这里。在本教程中,它说,我们可以以这种方式使用的大小和密度,特定资源:


  

RES /布局w600dp / main_activity.xml


我知道w600dp意味着可用宽度为600 dp。 但是,它的门户网站或风景?

下面是真实的案例:
我想设计一个全宽标题图片为我的门户模式Android应用程序。这个程序是针对三星Galaxy S4,其中有5.0英寸,1080x1920像素,441 dpi的。这意味着,我的标题图片必须是1080像素。正如前面提到的Andr​​oid的教程,在Android中,PX = DP *(DPI / 160);在三星Galaxy S4的例子,1080px宽度为391dp。 所以我需要在申报布局


  

RES /布局w391dp / main_activity.xml



  

RES /布局w320dp / main_activity.xml


当我用Photoshop创建我的头形象,我需要设置我的形象参数为1080的宽度,高度40和441dpi ?之后我得到的图像,我需要把这个形象


  

RES /绘-xhdpi /



  

RES /绘-w600dp /



解决方案

可用宽度值就会产生变化时,横向和纵向之间的方向改变目前的实际宽度相匹配。

如果你想为横向和纵向添加限定符名称提供不同的布局/资源 -land -port 分别。更多信息请访问<一个href=\"http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources\"相对=nofollow> Android文档

如果你想填补所有可用的宽度不想想dpi的。如果设备宽度为1080px,那么你需要用1080px的图像。但是,如果你想要的图像通过应用这些因素看起来是一样的diferent设备与diferent密度然后计算出它的尺寸:

LDPI = 0.75结果
MDPI = 1结果
华电国际= 1.5结果
xhdpi = 2结果
xxhdpi = 3

这是不可能在这里做关于这个问题的完整说明,我的英语是不够的这样。

Today, I read the android tutorial about supporting multiple screen. I got some problems here. In the tutorial, it says we can use size and density-specific resource in this way:

res/layout-w600dp/main_activity.xml

I know that w600dp means the available width is 600dp. But is it for portal or landscape?

Here is real case: I want to design a full width header image for my android app in portal mode. This app is targeted for Samsung Galaxy S4, which has 5.0 inches, 1080x1920 pixels with 441 dpi. That means my header image need to be 1080 pixels. As android tutorial mentioned, in android, px = dp * (dpi/160); In Samsung Galaxy S4 example, 1080px width is 391dp. So do I need to declare the layout in:

res/layout-w391dp/main_activity.xml

or

res/layout-w320dp/main_activity.xml

When I am using Photoshop to create my header image, do I need to set my image parameter as 1080 width, 40 height and 441dpi? After I get the image, do I need to put this image in:

res/drawable-xhdpi/

or

res/drawable-w600dp/

解决方案

The available width value will change when the orientation changes between landscape and portrait to match the current actual width.

If you want provide different layouts/resources for landscape and portrait add the qualifier name -land or -port respectively. See more at Android documentation

If you want fill all the available width don't think about dpi. If device width is 1080px then you need an image with 1080px. However, if you want an image look the same at diferent devices with diferent density then calculate its dimensions by applying these factors:

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

It is not possible here to do a full explanation on this subject, and my English is not enough for such.

这篇关于使用Android应用的设计规模和比重,资源问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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