[英]Can't format my layout
我正在嘗試將帶有橫幅廣告的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的入門者。 我想念的東西很小。
您需要在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
您在LinearLayout中缺少尾部的'>'。 因此,該部分應為:
<LinearLayout
android:layout_alignParentBottom="true"
android:id="@+id/adViewContainer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.