我正在尝试展示 Admob
广告,但这仅适用于横向模式,而不适用于正常模式。
layout-land/main.xml
和 layout/main.xml
是相同的! (现在是这样,因为我删除了其他所有内容来查找错误)
<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>
最佳答案
从相对布局中删除填充。当祖先 View 被填充时,AdMob 表现不佳。
<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 布局可以横向工作,但不能正常方向工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4281349/