在横向模式下通过广告填充屏幕的难度

时间:2012-08-18 09:25:17

标签: android

我在我的应用程序中使用广告。当模拟器在纵向模式下工作时工作正常但是当我将模拟器转换为横向模式时,即使我已经给出了android:layout_width =“它也会填充水平屏幕match_parent”。请告诉我如何解决这个问题。

这是xml文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world"
        />

     <com.google.ads.AdView
        android:id="@+id/ad"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="a1501e5633125fb"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR, 123456789ABCDEF" />


</RelativeLayout>

1 个答案:

答案 0 :(得分:6)

您应该使用Smart Banner

智能横幅广告是一种新的广告单元(自v6.0.0起),可以在不同设备上以任意方向在任何屏幕尺寸上呈现屏幕范围的横幅广告。智能横幅通过“巧妙地”检测手机当前方向的宽度,并使广告视图的大小,帮助处理不同设备中不断增加的屏幕碎片。