Android XML 布局可以横向工作,但不能正常方向工作

标签 android xml android-layout admob landscape

我正在尝试展示 Admob 广告,但这仅适用于横向模式,而不适用于正常模式。

layout-land/main.xmllayout/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/

相关文章:

Android - 从位置 A(索引)检查位置 B(索引)是否在 GridView 布局中与它成对角线,而不管是否接近

android - 在基于TabLayout的应用程序上实现屏幕旋转

java - intellij android hello world 不起作用 "Error loading preferences"

android - 为什么我的应用程序对 Galaxy Nexus 用户不可用,即使它在过去是可用的?

android - 如何创建 3 个连接的按钮?

android - 在android中按下按钮时缩小动画

java - Android:具有动态颜色的ListView

android - Android Studio 1.5如何在XML中添加Button id?

php - 用php提取xml中的youtube

java - Android UI 中的相对位置