0

This is the XML code:

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
    android:layout_height="wrap_content">

<RelativeLayout
        android:id="@+id/relative_layout_main"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

    <com.adsdk.sdk.banner.AdView
        android:id="@+id/ad_1"
        android:layout_width="300dp"
        android:background="#000000"
        android:layout_height="50dp"
        request_url="http://my.mobfox.com/request.php"
        publisherId="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        location="true"
        animation="true" />

    <TextView
        android:textIsSelectable="true"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:textStyle="bold"
        android:id="@+id/error_view_2"
        android:layout_marginTop="20dp"
    android:layout_below="@id/ad_1"
        android:text="@string/gen_mess_err" />    

    <TextView
        android:textIsSelectable="true"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:layout_below="@id/error_view_2"
        android:id="@+id/error_view_1" />

    <com.adsdk.sdk.banner.AdView
        android:id="@+id/ad_2"
        android:layout_width="300dp"
        android:background="#000000"
        android:layout_height="50dp"
        request_url="http://my.mobfox.com/request.php"
        publisherId="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        android:layout_below="@id/error_view_1"
        android:gravity="bottom"
        location="true"
        animation="true" />

</RelativeLayout>

What i want is to set the ads one on the top and one on the botton of the screen, and the textview in the center of the screen, but this doen't work. How can I do?

Thx in advance :)

Gimmy88
  • 295
  • 2
  • 5
  • 13

3 Answers3

1

Why is the layout_height attribute of the ScrollView set to wrap_content? It should be match_parent in order to fill the screen, so that the ads are placed in top and bottom.

Also, the property fill_parent is obsolete and match_parent is its newer value :)

jaibatrik
  • 6,770
  • 9
  • 33
  • 62
1

Change your XML code to this

android:fillViewport must be set to true - When set to true, this attribute causes the scroll view’s child to expand to the height of the ScrollView if needed. When the child is taller than the ScrollView, the attribute has no effect.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
<RelativeLayout
    android:id="@+id/relative_layout_main"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <com.adsdk.sdk.banner.AdView
        android:id="@+id/ad_1"
        android:layout_width="300dp"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        animation="true"
        location="true"
        publisherId="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        request_url="http://my.mobfox.com/request.php"
        android:background="#000000"
        android:gravity="center" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/error_view_2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:text="@string/gen_mess_err"
            android:textIsSelectable="true"
            android:textStyle="bold" />
        <TextView
            android:id="@+id/error_view_1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textIsSelectable="true" />
    </LinearLayout>
    <com.adsdk.sdk.banner.AdView
        android:id="@+id/ad_2"
        android:layout_width="300dp"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_below="@id/error_view_1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"
        animation="true"
        location="true"
        publisherId="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        request_url="http://my.mobfox.com/request.php"
        android:background="#000000"
        android:gravity="bottom" />
</RelativeLayout>

Sankar V
  • 4,794
  • 3
  • 38
  • 56
  • thanks, it works :) however i tried to use android:layout_alignParentBottom="true" in my code and modifying some parameters it worls too, thank anyway :) – Gimmy88 Apr 10 '13 at 14:25
0

Thy this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    >
    <com.adsdk.sdk.banner.AdView
            android:id="@+id/ad_1"
            android:layout_width="fill_parent"
            android:background="#000000"
            android:layout_height="wrap_content"
            request_url="http://my.mobfox.com/request.php"
            publisherId="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            android:layout_centerHorizontal="true"
            android:gravity="center"
            location="true"
            animation="true"  />

    <ScrollView
            android:id="@+id/relative_layout_main"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            >

    <TextView
            android:textIsSelectable="true"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:textStyle="bold"
            android:id="@+id/error_view_2"
            android:layout_marginTop="20dp"
            android:text="string/gen_mess_err" />

    <TextView
            android:textIsSelectable="true"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:id="@+id/error_view_1" />
    </ScrollView>

    <com.adsdk.sdk.banner.AdView
            android:id="@+id/ad_2"
            android:layout_width="fill_parent"
            android:background="#000000"
            android:layout_height="wrap_content"
            request_url="http://my.mobfox.com/request.php"
            publisherId="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            android:layout_marginTop="-51dp"
            android:gravity="bottom"
            location="true"
            animation="true"
            />

Hope its help.

jimpanzer
  • 3,470
  • 4
  • 44
  • 84