2

我正在构建一个应用程序,想在多个屏幕上运行它,外观完全相同。所以我尝试了最差(根据我)和最好的方法(根据开发人员)创建三个单独的 xml 文件文件夹以支持大、中、小屏幕。我的文件夹名称是布局(根据开发人员的说法,它是默认设置,适用于中型屏幕 WQVGA 400)、大布局(WVGA800)和小布局(QVGA)。但是,如果我更改布局文件夹(默认一个)中的文件(在所有三个同名文件夹中)中的某些内容,则该更改适用于大型和中型,但不适用于小型。无论我在布局大文件夹的 xml 文件中进行什么更改,都不适用于大屏幕显示,但布局-small 的更改适用于小屏幕。

4

3 回答 3

1

根据项目,最简单的方法是在 values 文件夹中为每个屏幕尺寸创建一个“styles.xml”文件:

values  //default
values-small
values-large
varlues-xlarge

然后,您只需要管理 4 个不同样式的文件(更改长度、边距、字母大小等)。如果需要,您还可以添加@Herry 所说的其他配置(大,土地,..)。

于 2012-05-03T08:22:13.560 回答
1

您可以在您的 android 项目中使用以下文件夹结构。

 1.layout This Use For Default Layout Files  // layout for normal screen size ("default")
   2.layout-land For Use in Landscape Mode
   3 layout-large     // layout for large screen size
   4.layout-large-long
   5.layout-large-long-land
   6.layout-large-notlong
   7.layout-large-notlong-land
   8.layout-ldpi
   9.layout-normal-long
   10.layout-normal-long-land
   11.layout-normal-notlong
   12.layout-normal-notlong-land
   13.layout-small   // layout for small screen size
   14.layout-small-land
   15.layout-xlarge      // layout for extra large screen size
   16.layout-xlarge-land   // layout for extra large in landscape orientation
于 2012-05-03T06:50:53.777 回答
0

"But however if i change something in a file(which is in all three folders by same name) in layout folder(default one) that change is applying to both large and medium but no applying to small."

Answer to this is, "Since you have different layout folder for small, medium and large screen then change made to large screen won't reflect for small screen. You will have to make the change in small-screen layout file as well.

But, as you said, your UI for all different sizes of devices is same then you should never create different layout folders. Only one layout folder is enough, Android will take care of rendering on different screen sizes during run time. Also go through this link http://developer.android.com/guide/practices/screens_support.html. After reading this you will be able to make your own decision on the type UI design you want for your application.

于 2012-05-03T06:54:41.253 回答