智能横幅容器视图不会调整 [英] Smart banner container view won't resize

查看:145
本文介绍了智能横幅容器视图不会调整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于以下布局为主要活动的内容视图

Given the following layout for a content view of a main activity

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".CordovaApp"
    tools:ignore="MergeRootFrame" >

    <LinearLayout
        android:id="@+id/layout_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:layout_above="@+id/layout_ad" >
    </LinearLayout>

    <RelativeLayout
        android:id="@+id/layout_ad"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:orientation="vertical" >

        <com.google.android.gms.ads.AdView
            android:id="@+id/view_ad"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="ca-app-pub-3940256099942544/6300978111" >
        </com.google.android.gms.ads.AdView>
    </RelativeLayout>

</RelativeLayout>

我不能让AdMob的智能横幅在方向改变的工作。

I can't make AdMob's smart banners to work upon orientation change.

如果我开始在横向模式下,我得到高度32.修改方向为纵向不会改变 layout_ad 高度的智能旗帜,我得到这个错误。

If I start in landscape mode, I get a smart banner of height 32. Changing orientation to portrait doesn't change layout_ad height and I get this error

没有足够的空间来展示广告。需要480x32 DP,但只具有320x455 DP

Not enough space to show ad. Needs 480x32 dp, but only has 320x455 dp.

推荐答案

AD浏览报需要,如果你正在使用SMART_BANNER和处理自己的配置变化来重新创建。否则,AD浏览大小不得到改变,但请求仍然是在新的方向全宽的广告,因此它不适合。重塑AD浏览报在这种情况下,可能会更容易为你做的code不是通过XML。

The AdView needs to be recreated if you're using SMART_BANNER and handling your own configuration changes. Otherwise, the AdView size doesn't get changed, but the request is still for a full width ad in the new orientation, and so it doesn't fit. Recreating the AdView in this case may be easier for you to do in code than via XML.

这篇关于智能横幅容器视图不会调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆