Note that there are some explanatory texts on larger screens.

plurals
  1. POListView taking up all space, when trying to use an Admob Adview in Android
    primarykey
    data
    text
    <p>I am trying to get Google Admob advertisements to display on the main screen of an app that consists of a ListView. Unfortunately, the ListView is taking up all of the space on the screen, and then the advertisement appears over the top of it. I have tried putting the ListView at the top, followed by an AdView, and I've also tried putting the AdView at the top, followed by the ListView, but nothing works.</p> <p>If I set the size of the LinearLayout enclosing the ListView to a fixed height (eg, 200px) then it it limits the size and fixes the problem, but I don't want to do this, because screen heights of Android devices vary so much. Is there no way to tell the ListView to not take up all the space without setting a fixed size?</p> <p>My code is below, I'd be grateful for any help:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_alignParentTop="true" android:id="@+id/ad_layout" android:orientation="vertical" android:gravity="top" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;com.google.ads.AdView android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adUnitId="AD_UNIT_ID" ads:adSize="BANNER" ads:loadAdOnCreate="true"/&gt; &lt;/LinearLayout&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_alignParentBottom="true" android:layout_below="@+id/ad_layout" android:orientation="vertical" android:gravity="bottom" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ListView android:id="@id/android:list" android:layout_width="fill_parent" android:layout_height="wrap_content"/&gt; &lt;TextView android:id="@+id/android:empty" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/no_hosts"/&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload