Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 根目录下文档中的标记必须格式正确_Android_Eclipse_Domdocument_Markup - Fatal编程技术网

Android 根目录下文档中的标记必须格式正确

Android 根目录下文档中的标记必须格式正确,android,eclipse,domdocument,markup,Android,Eclipse,Domdocument,Markup,我在XML中遇到错误“根目录下文档中的标记必须格式正确”。我不确定是什么原因造成的,以下是我的代码: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/TopTwoButtons" android:layout_width="fill_parent" android:layout_height="wrap_content" android:backgroun

我在XML中遇到错误“根目录下文档中的标记必须格式正确”。我不确定是什么原因造成的,以下是我的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TopTwoButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_meduim"
android:gravity="center_horizontal" >

<ImageView
    android:id="@+id/ListButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="39dp"
    android:layout_marginTop="130dp"
    android:src="@drawable/list_button_medium" />

<ImageView
    android:id="@+id/SearchButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignTop="@+id/ListButton"
    android:layout_marginLeft="20dp"
    android:src="@drawable/search_button_medium" />
</RelativeLayout>


<RelativeLayout
android:id="@+id/BottomTwoButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/TopTwoButtons"
android:gravity="center_horizontal" >

<ImageView
    android:id="@+id/InfoButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_centerInParent="true"
    android:layout_marginLeft="30dp"
    android:src="@drawable/info_button_medium" />

<ImageView
    android:id="@+id/PopularButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerInParent="true"
    android:layout_marginRight="30dp"
    android:src="@drawable/popular_button_medium" >



</RelativeLayout>


更新代码,仍然出现错误“根目录下文档中的标记必须格式正确”

任何布局文件都应该有一个根元素。这两个相对布局将是根的子元素

您的代码应该如下所示

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="fill_parent" android:layout_height="wrap_content" >

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/TopTwoButtons" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/background_meduim" android:gravity="center_horizontal" >

    <ImageView
     android:id="@+id/ListButton"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentRight="true"
     android:layout_alignParentTop="true"
     android:layout_marginRight="39dp"
     android:layout_marginTop="130dp"
     android:src="@drawable/list_button_medium" />

    <ImageView
     android:id="@+id/SearchButton"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentLeft="true"
     android:layout_alignTop="@+id/ListButton"
     android:layout_marginLeft="20dp"
     android:src="@drawable/search_button_medium" />
     </RelativeLayout>
     <RelativeLayout android:id="@+id/BottomTwoButtons"    android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/TopTwoButtons" android:gravity="center_horizontal" >

     <ImageView
     android:id="@+id/InfoButton"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentLeft="true"
     android:layout_centerInParent="true"
     android:layout_marginLeft="30dp"
     android:src="@drawable/info_button_medium" />

     <ImageView
     android:id="@+id/PopularButton"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentRight="true"
     android:layout_centerInParent="true"
     android:layout_marginRight="30dp"
     android:src="@drawable/popular_button_medium" >
     </RelativeLayout>
</RelativeLayout>