我正在開發一個android項目,並剛下載了admob sdk的最新版本。將admob廣告定位到屏幕底部
我想將廣告放置在屏幕的底部,但沒有任何我嘗試似乎工作。
下面是佈局的XML代碼
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView android:id="@+id/password_noRecords"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:text="There are currently\nno saved logins"
android:textSize="20dp"
android:textStyle="bold|italic"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
</ListView>
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY_ID"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, emulator-5554"
ads:loadAdOnCreate="true">
</com.google.ads.AdView>
</LinearLayout>
我曾試圖使ListView控件以及在高度,但隨後在logcat的是說,有沒有足夠的空間來展示廣告的LinearLayout FILL_PARENT 。
我也嘗試在線性佈局中包裝廣告,並說對齊parent bottom = true,但這並沒有什麼區別。
而是將廣告直接放置在列表視圖的底部,因此如果列表視圖爲半空,則廣告位於屏幕中間。
我想要的是廣告總是在屏幕底部可見,不管列表視圖有多大或多小。
感謝您提供的任何幫助。
它不是android:alignParentBottom =「true」,它是android:layout_alignParentBottom =「true」 – Marc
好抓住@Marc,我在我的答案中糾正了它。 – FoamyGuy