Android的XML布局工作在景观,但不是在正常的方向 [英] Android XML Layout works in landscape but not in normal orientation
本文介绍了Android的XML布局工作在景观,但不是在正常的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想显示 Admob的
广告,但它只适用于景观,但不是在正常模式下。
布局陆/ main.xml中
和布局/ main.xml中
都是一样的! (当然现在他们是因为我删除一切去寻找错误的)
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:的myapp =http://schemas.android.com/apk/res/test.testpkg
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@可绘制/背景
机器人:填充=10dip>
< com.admob.android.ads.AdView
机器人:ID =@ + ID /广告
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
的myapp:的backgroundColor =#000000
的myapp:primaryTextColor =#FFFFFF
的myapp:secondaryTextColor =#CCCCCC/>
< / RelativeLayout的>
解决方案
从相对布局中取出的填充。 AdMob的没有发挥好当的祖先视图被填充。
< RelativeLayout的
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:的myapp =http://schemas.android.com/apk/res/test.testpkg
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:背景=@可绘制/背景
>
< com.admob.android.ads.AdView
机器人:ID =@ + ID /广告
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
的myapp:的backgroundColor =#000000
的myapp:primaryTextColor =#FFFFFF
的myapp:secondaryTextColor =#CCCCCC
/>
< / RelativeLayout的>
I'm trying to display an Admob
ad but this only works in Landscape but not in normal mode.
layout-land/main.xml
and layout/main.xml
are the same! (well now they are because i deleted everything else to find the bug)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/test.testpkg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
android:padding = "10dip" >
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC" />
</RelativeLayout>
解决方案
Remove the padding from your Relative Layout. AdMob doesn't play nice when an ancestor View is padded.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/test.testpkg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
>
<com.admob.android.ads.AdView
android:id="@+id/ad"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC"
/>
</RelativeLayout>
这篇关于Android的XML布局工作在景观,但不是在正常的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文