0

I want to show the ad banner at the bottom of the page. Actually the list fills the entire screen. How do I show the ad?

Here is my layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="de.foo.foo.MainActivity$PlaceholderFragment" >

    <Fragment
        android:id="@+id/list_fragment"
        android:name="de.foo.foo.MyListFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <Fragment
        android:id="@+id/ad_fragment"
        android:name="de.foo.foo.AdFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


</LinearLayout>
EdmDroid
  • 1,350
  • 1
  • 11
  • 25
gurehbgui
  • 14,236
  • 32
  • 106
  • 178
  • take a look at this answer, it might help: http://stackoverflow.com/questions/5380383/how-to-get-ad-to-show-at-bottom-of-screen-without-overlap – Don Kelley Mar 31 '14 at 17:15
  • maybe try this answer also - frame layout can work well in your scenario: http://stackoverflow.com/questions/19129992/android-overlay-at-bottom-of-the-screen – Don Kelley Mar 31 '14 at 17:17

1 Answers1

1

Use RelativeLayout instead of LinearLayout.

Or here other way:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="de.foo.foo.MainActivity$PlaceholderFragment" >

    <Fragment
        android:id="@+id/ad_fragment"
        android:name="de.foo.foo.AdFragment"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />// here

    <Fragment
        android:id="@+id/list_fragment"
        android:name="de.foo.foo.MyListFragment"
        android:layout_width="match_parent"
        android:layout_weight="1" // here
        android:layout_height="0dp" /> // here


</LinearLayout>

list_fragment will fill all space except space that needed for ad_fragment

Divers
  • 9,531
  • 7
  • 45
  • 88