Alex
Alex

Reputation: 13

How to get admob banner shown in bottom true main.xml

I've made a simple webview app and I got the banner working, but I want the banner in the bottom. I have tried a lot but I cant get it to work. Hope someone can help me here.

This is the code in the main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"

    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#000000"
    android:id="@+id/mainLayout">
    <com.google.android.gms.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="ca-app-pub-9380760713574559/3453176828"
                         ads:adSize="SMART_BANNER"/>

    <ImageView android:id="@+id/splashScreen"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:visibility="visible"
        android:src="@drawable/splash"
        />
    <WebView 
        android:id="@+id/mainWebView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="gone"
    />
</LinearLayout>

Upvotes: 1

Views: 3355

Answers (3)

Bobby
Bobby

Reputation: 6255

AdView.LayoutParams adViewParams = new AdView.LayoutParams(AdView.LayoutParams.WRAP_CONTENT,AdView.LayoutParams.WRAP_CONTENT); adViewParams.addRule(AdView.ALIGN_PARENT_BOTTOM); adViewParams.addRule(AdView.CENTER_HORIZONTAL); layout.addView(adMobView, adViewParams);

Upvotes: 0

NarenderNishad
NarenderNishad

Reputation: 1068

Well I Tried this. Hope it Help you

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="5"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/splashScreen"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:visibility="visible" />

        <WebView
            android:id="@+id/mainWebView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:visibility="gone" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="bottom"
        android:orientation="vertical" >

        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="ca-app-pub-9380760713574559/3453176828" >
        </com.google.android.gms.ads.AdView>
    </LinearLayout>

</LinearLayout>

Upvotes: 3

essess
essess

Reputation: 277

Add following property within com.google.android.gms.ads.AdView tag

android:layout_alignParentBottom="true"

Upvotes: 0

Related Questions