2014-03-30 36 views
2

我试图放置带有横幅广告的LinearLayout - 位于RelativeLayout的底部。无法格式化我的布局

我试图去实现它:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    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" > 

    <ListView 
       android:id="@+id/allJokesList" 
       android:layout_height="wrap_content" 
       android:layout_width="match_parent"> 
    </ListView> 

    <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="MY_AD_UNIT_ID" 
         ads:adSize="BANNER"/> 
    </LinearLayout> 

</RelativeLayout> 

但它总是给我这个错误:

error: Error parsing XML: unbound prefix 

我知道我的格式是完全搞砸了,但我不能找到一种方法使其有效。

我只是需要一个线索,因为我是一个在android和xml的初学者。我错过了我知道的很小的东西。

回答

2

您必须XML布局

xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 

!因为你

ads:adUnitId="MY_AD_UNIT_ID" // see this attribute 
+0

谢谢你的帮助!:) – chility

+1

不客气 – Raghunandan

1

您错过了LinearLayout的尾部'>'。所以这部分应该是:

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

的根元素的下面我刚刚编辑了代码和错误。 :( – chility