在Android上的ImageView上重叠Admob广告

时间:2014-06-02 12:37:39

标签: android imageview admob

我在android xml中使用了以下内容。每当我滚动页面时,admob广告都会从底部重叠Image的某些部分。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#31352e" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical" >

            <ImageView
                android:id="@+id/imageView1"
                android:layout_width="match_parent"
                android:layout_height="330dp"
                android:background="@drawable/pic_one"
                android:scaleType="fitXY" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_width="fill_parent"
                android:layout_height="330dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:scaleType="fitXY"
                android:src="@drawable/pic_two" />

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="fill_parent"
                android:layout_height="330dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:scaleType="fitXY"
                android:src="@drawable/pic_three" />

            <ImageView
                android:id="@+id/imageView4"
                android:layout_width="fill_parent"
                android:layout_height="330dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:scaleType="fitXY"
                android:src="@drawable/pic_four" />

            <ImageView
                android:id="@+id/imageView5"
                android:layout_width="fill_parent"
                android:layout_height="330dp"
                android:layout_margin="5dp"
                android:background="#fff"
                android:scaleType="fitXY"
                android:src="@drawable/pic_five" />
        </LinearLayout>
    </ScrollView>

    <com.google.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
        android:id="@id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="ID here"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR" />

</RelativeLayout>

但是,广告仍然与ImageView重叠

如何在广告加载时调整屏幕?

2 个答案:

答案 0 :(得分:0)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/g"
        android:gravity="center"
        android:orientation="horizontal" >

              <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/black"
            android:gravity="center"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/activity_main_content_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:paddingBottom="8dp"
                android:paddingTop="8dp"
                android:text="APPLICATION NAME"
                android:textAppearance="?android:attr/textAppearanceMedium" />
        </LinearLayout>
    </LinearLayout>

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="4.12"
        android:background="@color/white" >

        <ImageView
            android:id="@+id/Large_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="centerCrop"
            android:src="@drawable/icn" />



         </RelativeLayout>

  <RelativeLayout
        android:id="@+id/rel"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
        android:background="@color/darkblue" >

  <com.google.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
            android:id="@+id/ad"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
           ads:adSize="BANNER"
             ads:loadAdOnCreate="true"
            ads:adUnitId="MY KEY " />  
    </RelativeLayout>


</LinearLayout>

答案 1 :(得分:0)

获取ImageView广告的最佳方式是using FrameLayout, 它只是在当前布局的基础上创建一个层