不能同时显示ListView和AdvView

I have an Activity in my app that simply displays some results from a search. This data is displayed using a ListView. This works well. I recently tried adding an Adview underneath it, but it simply doesn't display. What's more, it pushes my List View up to the top of the screen so that it can only occupy the top 20% or so of the screen - with only blank underneath.

Here is the display XML:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res/uk.co.redfruit.android.whogotwhat"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingTop="10dp"
    android:paddingBottom="10dp"
    >
    <ListView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:id="@+id/scanResults"
        android:paddingLeft="5dp" 
        android:paddingRight="5dp" 
        />
    <com.admob.android.ads.AdView 
        android:id="@+id/ad"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        myapp:backgroundColor="#000000"
        myapp:primaryTextColor="#FFFFFF"
        myapp:secondaryTextColor="#CCCCCC" 
        />
</LinearLayout>

What am I missing here?

#0

For starters, use android:orientation="vertical" on your LinearLayout, or it'll default to being a horizontal one. Secondly, try setting the LinearLayout's height to fill_parent and set your ListView height to 0px but with a layout_weight of 1. If it's still not behaving, I'd guess admob's AdView is behaving badly and ignoring the wrap_content directive -- try fixing its height to a specific size in dip (Admob ought to tell you what the sizes are that they'll be serving up there, anyways).

#1

Also, the Admob AdView does not display if it could not retrieve an ad. Check your LogCat to see if there are any AdMobSDK messages in there. You may need to add one house ad to your account to make sure it is working.

I would also put a layout_weight=1 on the AdView, maybe also try layout_height="wrap_content" on the ListView.

推荐文章

调用Render时缺少模板错误

调用Render时缺少模板错误

推荐文章

如何在Python中检测ftp服务器超时

如何在Python中检测ftp服务器超时

推荐文章

Merge语句:在临时表中输入记录值而不是DELETE

Merge语句:在临时表中输入记录值而不是DELETE

推荐文章

如何管理多个共享代码和配置的Rails应用程序和服务?

如何管理多个共享代码和配置的Rails应用程序和服务?

推荐文章

用漂亮的汤编写xml

用漂亮的汤编写xml

推荐文章

如何在flash中静音和取消静音多个嵌入音频曲目(actionscript 3)

如何在flash中静音和取消静音多个嵌入音频曲目(actionscript 3)

推荐文章

Silverlight:VisualStateManager.GetVisualStateGroups没有,我如何获取它们?

Silverlight:VisualStateManager.GetVisualStateGroups没有,我如何获取它们?

推荐文章

jQuery IE 9在点击“tbody”值中的元素后替换“tbody”值时崩溃

jQuery IE 9在点击“tbody”值中的元素后替换“tbody”值时崩溃

推荐文章

无法定位兄弟姐妹

无法定位兄弟姐妹

推荐文章

从C++ DLL.NET调用/编组中处理用户定义的异常

从C++ DLL.NET调用/编组中处理用户定义的异常

推荐文章

在App Engine SDK数据存储查看器中查看*更多*实体

在App Engine SDK数据存储查看器中查看*更多*实体

推荐文章

DropDownList不维护“用户模式菜单”选择器的ViewState

DropDownList不维护“用户模式菜单”选择器的ViewState

推荐文章

从sybase切换到oracle—注意事项?

从sybase切换到oracle—注意事项?

推荐文章

如何在Bash中的同一行上编写具有多个条件的IF语句?

如何在Bash中的同一行上编写具有多个条件的IF语句?

推荐文章

缓慢的PHP脚本导致MySQL服务器睡眠(使用pconnect())

缓慢的PHP脚本导致MySQL服务器睡眠(使用pconnect())

推荐文章

快速更新位字段以添加权限

快速更新位字段以添加权限