繁体   English   中英

Admob不会在所有设备上显示横幅

[英]Admob don't show the banner in all the device

我已经建立了这个main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:clipToPadding="true"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:clipToPadding="true"
        android:orientation="vertical"
        android:paddingBottom="@dimen/Space075"
        android:paddingLeft="@dimen/Space075"
        android:paddingRight="@dimen/Space075" >

        <!-- start no_account_page -->

        <include layout="@layout/no_account_page" />

        <!-- end  no_account_page -->

        <RelativeLayout
            android:id="@+id/content_accounts_present"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/Space200"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/AppLogo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/big_padlock" />

            <TextView
                android:id="@+id/SH5Are"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_marginLeft="@dimen/Space100"
                android:layout_toRightOf="@+id/AppLogo"
                android:text="@string/SH5Are"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@color/DarkRed"
                android:textSize="@dimen/text075" />

            <TextView
                android:id="@+id/ProtectingYou"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/SH5Are"
                android:layout_below="@+id/SH5Are"
                android:layout_marginTop="@dimen/SpaceMinus050"
                android:text="@string/ProtectingYou"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@color/DarkRed"
                android:textSize="@dimen/text100" />

            <TextView
                android:id="@+id/VerificationCodeList"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/ProtectingYou"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/ProtectingYou"
                android:paddingBottom="@dimen/Space150"
                android:text="@string/VerificationCodeList"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="@color/Black"
                android:textSize="@dimen/text075" />
        </RelativeLayout>

        <ListView
            android:id="@+id/user_list"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center|top"
            android:orientation="vertical"
            android:textColor="@color/Black" />
    </LinearLayout>

    <include layout="@layout/admob_banner" />

</LinearLayout>

这是admob_banner.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/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:layout_weight="2">

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        ads:adSize="BANNER"
        ads:adUnitId="THIS_IS_MY_ID" />

</LinearLayout>

但是,发生的动作会很响当当:在某些设备(我尝试过3.2英寸和5英寸的设备,第一个使用Android 2.3,第二个使用4.3)中,没有显示横幅。 在我的移动设备(带有Android 4.1的4.5英寸)中,横幅广告出现在页面底部,但没有出现。我要疯了。我的错误是什么?为什么有时出现而有时却没有出现?为什么没有出现在页面底部?有人可以帮我吗?

您的广告有时可能不会加载,但会针对以下布局:

<RelativeLayout ...> //outermost layout


<include layout="@layout/admob_banner" 
    android:id="@+id/banner"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
/>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/banner">
//The rest of your layout
</LinearLayout>

</RelativeLayout>

并删除横幅广告父级布局上的权重。 确实,您甚至根本不需要横幅的父级LinearLayout

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM