0

I have following xml design -

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentTop="true"
    android:background="@drawable/wall"
    android:orientation="vertical"
    tools:context="com.ahl.XXXXX.MainActivity" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/XXXXX"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.5"
            android:background="@color/XXXXX"
            android:onClick="openXXXXX"
            android:text="@string/XXXXX" 
            android:textColor="@color/White"/>

        <Button
            android:id="@+id/XXXXX"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1.5"
            android:background="@color/XXXXX"
            android:onClick="openXXXXX"
            android:text="@string/XXXXX" 
            android:textColor="@color/White"/>

        <Button
            android:id="@+id/XXXXX"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:background="@color/XXXXX"
            android:onClick="openXXXXX"
            android:text="@string/XXXXX"
            android:textColor="@color/White"/>

        <Button
            android:id="@+id/XXXXX"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/Gray"
            android:onClick="openXXXXX"
            android:text="@string/XXXXX"
            android:textColor="@color/White"/>
    </LinearLayout>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adViewB1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-6805003743867442/4243673212" >

    </com.google.android.gms.ads.AdView>

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <WebView
            android:id="@+id/WebView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </ScrollView>

</LinearLayout>

I want to float banner ad at the bottom of screen. I tried using relative layout but It is not working well with webview. I have seen other questions like this but here webview is causing some problems as it covers all the screen ... so I had to use linearlayout.

Do I have to float ad over webview OR over parent Linearlayout??

What changes I can do in the above XML to get the ad at the bottom of the screen.

user2952821
  • 743
  • 2
  • 6
  • 19
  • why does your webview cover the whole screen when you use relative layout? You can set its height. – sam Jan 01 '15 at 15:56

1 Answers1

1

I suspect what you mean is that you want the AdView to be displayed at the bottom of the screen. You really don't want to float the AdView over anything.

Set your WebView to expand to fill unused space using layout_weight="1" and have the AdView displayed below that. Eg.

<ProgressBar
    android:id="@+id/progressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"/>

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
>

    <WebView
        android:id="@+id/WebView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</ScrollView>

<com.google.android.gms.ads.AdView
    android:id="@+id/adViewB1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="ca-app-pub-6805003743867442/4243673212" >

</com.google.android.gms.ads.AdView>
William
  • 20,150
  • 8
  • 49
  • 91