【问题标题】:android layout overlay issueandroid布局覆盖问题
【发布时间】:2013-03-04 13:12:32
【问题描述】:

我是 android 的初学者。我使用 webview 和集成的 admob 广告横幅制作了一个 flash 游戏 android 应用程序,但它覆盖了 webview。我需要它看起来像这张图片http://i46.tinypic.com/2cosrjp.png 这是我的代码:

        <?xml version="1.0" encoding="utf-8"?>

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<RelativeLayout
android:id="@+id/lay"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

</RelativeLayout>

<com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="a1513fab869115a"
    ads:loadAdOnCreate="true"
    ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />

 </RelativeLayout>

【问题讨论】:

    标签: android xml layout admob


    【解决方案1】:

    在 webView 视图中添加 android:layout_below="+id/lay"

    <RelativeLayout
    android:id="@+id/lay"
    android:layout_below="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
    
    <WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
    
    </RelativeLayout>
    

    在广告视图中添加android:layout_alignParentTop="true"

    <com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    ads:adSize="BANNER"
    ads:adUnitId="a1513fab869115a"
    ads:loadAdOnCreate="true"
    ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
    

    【讨论】:

    • 太棒了!!可以减小广告横幅大小吗??
    • android:layout_height="40dp" 或者你可以在测试后给出的任何尺寸。
    • 把你的邮箱给我,以后联系你!
    【解决方案2】:

    尽管对于许多用例来说,RelativeLayout 可能是首选,但对于这个简单的视图,我会使用LinearLayout,这样会容易得多。

    【讨论】:

      【解决方案3】:

      我遇到了相反的错误,我希望我的应用显示为你的,但我无法得到它,我得到了你想要的答案。

      <?xml version="1.0" encoding="utf-8"?>
      <LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:ads="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical"
          android:weightSum="1">
      
      
          <com.google.android.gms.ads.AdView android:id="@+id/adView"
              android:layout_width="355dp"
              android:layout_height="wrap_content"
              ads:adUnitId="000000000000000000"
              ads:adSize="BANNER"
              android:layout_gravity="center_horizontal|bottom" />
      
          <WebView
              android:layout_width="match_parent"
              android:layout_height="fill_parent"
              android:id="@+id/tropas"
              android:layout_weight="1.01" />
      
      </LinearLayout>
      

      这是我的代码并在顶部显示 Aadmob 不覆盖 webview

      【讨论】:

        猜你喜欢
        • 2012-03-31
        • 2011-04-26
        • 1970-01-01
        • 1970-01-01
        • 2017-11-19
        • 2014-07-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-25
        相关资源
        最近更新 更多