0

我在我的应用程序上添加了 admob sdk 6.4,但它未能在应用程序上显示

logcat 显示以下错误消息

?:??: W/?(?): com.android.internal.widget.SizeAdaptiveLayout@425f9e70child 视图 android.widget.FrameLayout@424d1538 在 95px 处测量超出范围,限制在 96px

我的activity_mail.xml如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ns="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView
    android:id="@+id/picture"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/sexy" >
</ImageView>

<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#00000000"
    android:stretchColumns="*" >
</TableLayout>

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:layout_margin="3sp"
    android:layout_marginBottom="116dp"
    android:gravity="center"
    android:weightSum="2" >

    <Button
        android:id="@+id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Pattern #1" />

    <Button
        android:id="@+id/btn2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Pattern #2" />

    <Button
        android:id="@+id/btn3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OFF" />
</TableRow>

<com.google.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/tableRow1"
    ns:adSize="BANNER"
    ns:adUnitId="a152106a3311446 "
    ads:testDevices="37329DE7326D00EC" >
</com.google.ads.AdView>
</RelativeLayout>

我该如何解决?

4

2 回答 2

1

我不知道这是否会导致您的问题,但是在您的 AdView 中,您必须声明

   android:layout_above="@id/tableRow1"

但你有

   android:layout_above="@+id/tableRow1" <--the + is wrong

第二个是您的 adUnitId 最后有一个空白(顺便说一下,不要在 stackoverflow 中显示您的真实 ID)

于 2013-08-18T08:41:38.250 回答
1

将标签放入其中,因为 TableLayout 是 TableLayout 的父级并使用 android:layout_alignParentBottom="true" 属性。

<TableLayout
    android:id="@+id/tableLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"
    android:background="#00000000"
    android:stretchColumns="*" >

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:weightSum="2" >

    <Button
        android:id="@+id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Pattern #1" />

    <Button
        android:id="@+id/btn2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Pattern #2" />

    <Button
        android:id="@+id/btn3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OFF" />
</TableRow>
</TableLayout>

<com.google.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/tableLayout"
    ns:adSize="BANNER"
    ns:adUnitId="a152106a3311446 "
    ads:testDevices="37329DE7326D00EC" >
</com.google.ads.AdView>
于 2013-08-18T09:07:22.153 回答