我在Android项目中使用SMART_BANNER。它在纵向模式下正常工作,但当方向改变(到横向)时,横幅宽度保持不变。 这是我的adview布局:
<LinearLayout
android:id="@+id/adLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#000000"
android:orientation="vertical" >
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
app.backgroundColor ="#000000"
ads:adUnitId="xxxxxxx"
android:gravity="center" >
</com.google.android.gms.ads.AdView>
</LinearLayout>
我还尝试了android:layout_width="wrap_content"
包含横幅的LinearLayout和用于AdView的android:layout_width="match_parent"
- 没有任何反应。
答案 0 :(得分:0)
检查maniefest中没有类似下面的行 -
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
答案 1 :(得分:0)
是的,smart_banner在横向模式下不起作用。所以改变它
ads:adSize =“ BANNER”
答案 2 :(得分:0)
如果您在AdView已加载一个或多个广告之后更改应用程序的方向,则更改方向时,它不会自动调整视图的大小。
在这种情况下,您应该覆盖onConfigurationChanged
以跟踪方向更改,如果方向更改则重新创建AdView。 This堆栈溢出问题似乎有一个例子,但我自己还没有尝试过。
通常,横向模式下SMART_BANNER的填充率似乎很低。