Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.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
Java xml布局的问题_Java_Android_Xml - Fatal编程技术网

Java xml布局的问题

Java xml布局的问题,java,android,xml,Java,Android,Xml,我创建了以下xml布局: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingBottom="

我创建了以下xml布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".AllJokes" 
    android:background="@drawable/background">

    <ListView
              android:id="@+id/allJokesList"
              android:layout_height="wrap_content"
              android:layout_width="match_parent">
    </ListView>
</RelativeLayout>
<LinearLayout 
            android:layout_alignParentBottom="true" 
            android:id="@+id/adViewContainer"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content">

              <com.google.android.gms.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="ca-app-pub-code/code"
                         ads:adSize="BANNER"/>
    </LinearLayout>
为什么会这样

我知道它非常小,而且与根元素有关,但作为初学者,很难理解上下文


注:我在relativelayout之后添加linearlayout,因为正如谷歌广告指南中所描述的,这两个元素之间应该有一个空格。

出现问题的原因是您将
线性布局
放置在
相对布局
之外,相对布局是
线性布局
的父布局。您的根元素是
相对布局
,但是将
LinearLayout
放在根元素之外,这就是为什么会出现此错误


如果您希望在
RelativeLayout
之后有一个
线性布局
,我建议将另一个
RelativeLayout
线性布局
一起放在根元素中。

整个XML文件只能有一个根元素。这里有两个相对线和直线布局

尝试将LinearLayout放在RelativeLayout内(在末尾关闭容器)是否有办法在
列表视图
RelativeLayout
?:)之间留一个小间隙在
LinearLayout
中添加
android:layout\u marginTop
属性。
The markup in the document following the root element must be well-formed.