简体   繁体   中英

Admob advertisement seems like background

The advertisement is visible but it is not clickable and it looks as background image. What is the problem ? is this about xml or java code ? Here is xml

<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="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background1"
tools:context=".Search">

<RelativeLayout 
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<com.google.ads.AdView 
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="MY - ID"
ads:loadAdOnCreate="true"/>

<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" 
android:scrollingCache="false">
</ListView>
</RelativeLayout>
</RelativeLayout>

Here is java

    RelativeLayout RelativeLayout1 = (RelativeLayout)findViewById(R.id.RelativeLayout1);
AdView adView=new AdView(this,AdSize.SMART_BANNER,"MY - ID");
    RelativeLayout1.addView(adView);
    AdRequest request = new AdRequest();
    adView.loadAd(request);

The problem is on your XML Layout, you are using a RelativeLayout and adding two components on the same RelativeLayout, if you want to prevent the content to be overlap you need to set that on the layout adding something like:

android:layout_below="@+id/adView"

to the ListView , or you can use a LinearLayout, but I don't know how you want your layout...if you draw the layout I can try to help

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM