我正在开发一个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