DrawerLayout - 根元素后面的文档中的标记必须格式正确

时间:2013-12-04 20:06:57

标签: java android xml

我收到错误说明根元素后面的文档中的标记必须格式正确。我不确定为什么会发生这种情况 - 我相信我已经正确地格式化了一切。

XML:

   <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- The main content view -->

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- The navigation drawer -->

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#111"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout><com.google.android.youtube.player.YouTubePlayerView
    android:id="@+id/youtubeplayerview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />
<com.idg.omv.ui.widget.VideosListView
    android:id="@+id/videosListView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />
<RelativeLayout
    android:id="@+id/footer"
    android:layout_width="fill_parent"
    android:layout_height="70dip"
    android:layout_alignParentBottom="true" >

    <HorizontalScrollView
        android:id="@+id/groupScrollView"
        android:layout_width="fill_parent"
        android:layout_height="match_parent" >

        <ImageView
            android:id="@+id/selstation_up_btn"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:background="@color/darkgrey"
            android:scaleType="fitXY"
            android:src="@drawable/selstation_up_btn" />
    </HorizontalScrollView>

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:src="@drawable/scroll_lt_arrow" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:src="@drawable/scroll_rt_arrow" />

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout><android.support.v4.widget.Drawer

</android.support.v4.widget.DrawerLayout>

1 个答案:

答案 0 :(得分:1)

android.support.v4.widget.DrawerLayout是您的Outer Most Parent,因此您只需要在文件末尾关闭,所有SubViews所有within必须android.support.v4.widget.DrawerLayout仅限<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" > <!-- The main content view --> <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" /> <!-- The navigation drawer --> <ListView android:id="@+id/left_drawer" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:background="#111" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" /> <com.google.android.youtube.player.YouTubePlayerView android:id="@+id/youtubeplayerview" android:layout_width="match_parent" android:layout_height="wrap_content" /> <com.idg.omv.ui.widget.VideosListView android:id="@+id/videosListView" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <RelativeLayout android:id="@+id/footer" android:layout_width="fill_parent" android:layout_height="70dip" android:layout_alignParentBottom="true" > <HorizontalScrollView android:id="@+id/groupScrollView" android:layout_width="fill_parent" android:layout_height="match_parent" > <ImageView android:id="@+id/selstation_up_btn" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal" android:background="@color/darkgrey" android:scaleType="fitXY" android:src="@drawable/selstation_up_btn" /> </HorizontalScrollView> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:src="@drawable/scroll_lt_arrow" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:src="@drawable/scroll_rt_arrow" /> <android.support.v4.view.ViewPager android:id="@+id/view_pager" android:layout_width="match_parent" android:layout_height="match_parent" /> </RelativeLayout><RelativeLayout> </RelativeLayout> </android.support.v4.widget.DrawerLayout>

试试这个:

{{1}}