Create a parent vertical LinearLayout
and place your ListView
with layout weight as 2 and AdView
weight as 1. This will make sure ListView
will be at top and adjust its height based on AdView
. So that AdView
will be shown always at bottom.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<ListView
android:id="@+id/listView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/Red"
android:layout_weight="2"/>
<com.google.android.gms.ads.AdView
android:id="@+id/welcomeAdView"
android:layout_width="match_parent"
android:layout_height="100dp"
ads:adSize="SMART_BANNER"
ads:adUnitId=""
android:layout_weight="1"/>
</LinearLayout>
Also, change you code to just load the ad, Don't add the AdView
agin to the layout
AdView ad = (AdView) findViewById(R.id.ad);
AdRequest adRequest = new AdRequest.Builder().build();
ad.loadAd(adRequest);