Java xml布局的问题
我创建了以下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="
<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.