为什么XML用于Android的创建UI布局?布局、XML、Android、UI

2023-09-12 09:10:41 作者:喝了酱油耍酒疯

我想知道为什么我们使用 XML在Android上创建用户界面布局。我知道,它分离了楼内设有商务逻辑从设计,但什么是XML的比其他的意义?

I would like to know why we use XML for the creating user interface layouts in Android. I know that it decouples the buisness logic from the design but what is the significance of the XML other than that?

此外,我想知道自动生成 R.java 文件在此意义。所有我知道,它是根据变化的资源和它有助于我们通过自己的ID来访问窗口小部件和资源产生

Also I would like to know the significance of autogenerated R.java file in this. All I know that it is generated according to the changes in the resources and that it helps us to access the widgets and resources through their ids.

这将是巨大的,如果有人能够给出一个明确的概念在这两个方面的问题。

It would be great if someone could give a clear idea on these two aspects.

推荐答案

有关XML易于和efficient.Here是我从安卓您好埃德Brunnette这是有道理的读说不像是大家。

Unlike what everyone said about the xml being easy and efficient.Here is what i read from Hello Android from Ed Brunnette which made sense.

Android是有限的内存和功率的移动设备进行了优化,所以你可能会觉得奇怪,它使用XML如此普遍地。毕竟,XML是一个详细的,人类可读的格式不知道它的简洁和效率,对吧?

Android is optimized for mobile devices with limited memory and horsepower, so you may find it strange that it uses XML so pervasively. After all, XML is a verbose, human-readable format not known for its brevity or efficiency, right?

虽然编写程序的时候,你看到的XML,Eclipse的插件调用了Android资源编译器,AAPT,以preprocess XML转换成一个COM pressed二进制格式。**正是这种格式,而不是原始的XML文本,存储在设备上。

Although you see XML when writing your program, the Eclipse plug-in invokes the Android resource compiler, aapt, to preprocess the XML into a compressed binary format.**It is this format, not the original XML text, that is stored on the device.

这是这样回答,我一直在寻找的。(对不起,如果我的问题,否则的意思)。

This was the kind of answer that i was looking for.(sorry if my question meant otherwise).

这是XML被选中的原因是其熟悉和IDE工具,本身支持它的数量,主要是因为。开发人员可以选择JSON例如,仍然编译,要binary.The自动生成R.java文件是一个辅助的IDE,这样你可以得到自动完成的好处,当你要访问的资源。

The reason that XML was chosen is mainly because of its familiarity and the number of IDE tools that natively support it. The developers could have chosen JSON for example and still compiled that to binary.The auto-generated R.java file is a helper for the IDE so that you can get the benefit of autocomplete when you want to access a resource.