0

これは XML コードです。

<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>

私が望むのは、広告を画面の上部と下部に 1 つずつ、テキストビューを画面の中央に設定することですが、これは機能しません。どのようにできるのか?

事前にThx :)

4

3 に答える 3

1

XMLコードをこれに変更します

android:fillViewport must be set to true- true に設定すると、この属性により、必要に応じてスクロール ビューの子が ScrollView の高さまで拡張されます。子が ScrollView よりも背が高い場合、属性は効果がありません。

<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>

于 2013-04-10T14:14:18.457 に答える
1

layout_heightセットの属性が にScrollView設定されているのはなぜwrap_contentですか? match_parent広告が上下に配置されるように、画面いっぱいに表示する必要があります。

また、プロパティfill_parentは廃止されmatch_parent、新しい値になります:)

于 2013-04-10T14:04:25.937 に答える
0

あなたのこれ

<?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"
            />

その助けを願っています。

于 2013-04-10T14:09:52.233 に答える