我创建了两个布局文件。
创建此XML的Android xml布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>和Android XML文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>从外观上看,它们都是一样的。既然它们都在创建相同的xml,那么什么时候应该使用其中一个呢?
发布于 2013-01-24 03:42:34
是的,它们很幸运是一样的,没有不同类型的xml。重要的是xml的位置(布局、值等)。
在eclipse中,IDE视图可能有一点不同,如果您创建一个Android XML文件而不是一个布局文件,我不确定您是否有图形布局视图(这是一个细节,因为,您仍然可以添加此视图;)
但结果apk将是相同的。
发布于 2013-01-24 08:45:24
之所以要使用Android XML,是因为您想要使用布局工具( GUI布局编辑器)。Eclipse IDE将以不同的方式对此文件做出反应。
但是,代码是相同的,所以您创建的APK也是相同的-这在您的最终输出中并不重要。
我总是使用Android XML文件,所以它们可以更好地集成到ADT工具中。
发布于 2019-07-19 19:25:01
据我所知,唯一的区别是在xml中不能同时使用"android:layout-width:“和"android:layout-height:”属性,这使得xml适用于菜单和项目栏以及其他用途。
https://stackoverflow.com/questions/14419198
复制相似问题