Question

I am having banner ad in the bottom of the home page as below,

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="0dp"
    tools:context=".MainActivity" >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="10dp"
        android:contentDescription="@string/background"
        android:scaleType="fitXY"
        android:src="@drawable/bg" />

    <RelativeLayout
        android:id="@+id/riverLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/navBar"
        android:background="@drawable/item_bg"
        android:paddingBottom="10dp"
        android:paddingLeft="0dp"
        android:paddingRight="0dp"
        android:paddingTop="0dp" >

        <ImageView
            android:id="@+id/riverImage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="20dp"
            android:contentDescription="@string/river_image_desc" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@id/riverImage"
            android:layout_marginLeft="5dp"
            android:text="@string/river_text"
            android:textColor="#4494CA"
            android:textSize="17sp"
            android:textStyle="bold" />

        <com.scringo.ScringoCommentButton
            android:id="@+id/riverCommentButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginTop="5dp"
            android:layout_below="@id/riverImage"
            android:layout_marginRight="50dp" />

        <com.scringo.ScringoLikeButton
            android:id="@+id/riverLikeButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/riverCommentButton"
            android:layout_below="@id/riverImage"
            android:layout_marginTop="5dp"
            android:layout_marginRight="10dp" />
    </RelativeLayout>

    <Button
        android:id="@+id/riverFeedButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/riverLayout"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:text="@string/river_button_text" />

    <Button
        android:id="@+id/openChatRoomButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/riverFeedButton"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:text="@string/discover" />

    <Button
        android:id="@+id/openInboxButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/openChatRoomButton"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="10dp"
        android:text="@string/open_inbox_button_text" />

    <com.scringo.ScringoLeftRibbonButton
        android:id="@+id/activationRibbonLeft"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="350dp" />

    <!--
        <com.scringo.ScringoRightRibbonButton
        android:id="@+id/activationRibbonRight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginTop="350dp" />
    -->
    <RelativeLayout
    android:id="@+id/toplayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <com.mopub.mobileads.MoPubView
        android:id="@+id/adview"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="10dp"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="@drawable/spacer_old"  />
    </RelativeLayout>
</RelativeLayout>

The banner ad view

'<com.mopub.mobileads.MoPubView   ../>' 

should display in all pages something like static/fixed at the bottom of each page of the application, that means i should not add this view in all the pages but still it should display at the bottom of all the pages(like image poping up from the bottom). How to do this

Was it helpful?

Solution

Move the android:layout_alignParentBottom attribute from com.mopub.mobileads.MoPubView to its parent RelativeLayout as below

<RelativeLayout
    android:id="@+id/toplayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical" >

    <com.mopub.mobileads.MoPubView
        android:id="@+id/adview"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/spacer_old" />
</RelativeLayout>

OTHER TIPS

or try this

    <com.mopub.mobileads.MoPubView
        android:id="@+id/adview"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_marginTop="10dp"
        android:background="@drawable/spacer_old" />
</RelativeLayout>
    android:id="@+id/toplayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="">

    <com.mopub.mobileads.MoPubView
        android:id="@+id/adview"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="10dp"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="@drawable/spacer_old"  />
    </RelativeLayout>
</RelativeLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top