2

スクロールビュー内に3つのビューがあり、scollレイアウト全体に分散したいと思います。私はそれが正しく機能しないので、誰かが問題を見てくれることを願っています。

私が欲しいのはスクロールビュー内です:

<scrollview>
  <linear or relative view?>
    (filler)
    moneywheels
    (filler)
    timewheels
    timeWheelsText
    (filler)
  </linear or relative view?>
</scrollview>

ご助力ありがとうございます!

<ScrollView
    android:id="@+id/ScrollView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:orientation="vertical"
        android:weightSum="3" >

        <LinearLayout
            android:id="@+id/fil1"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <LinearLayout
            android:id="@+id/moneyWheels"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0">

            <!-- content -->

        </LinearLayout>

        <LinearLayout
            android:id="@+id/fill2"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <LinearLayout
            android:id="@+id/timeWheels"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:background="@drawable/time"
            android:padding="@dimen/padding" >

            <!-- content -->

        </LinearLayout>

        <LinearLayout
            android:id="@+id/timeWheelsText"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_gravity="center"
            android:layout_weight="0"
            android:gravity="top|center" >

            <!-- content -->

        </LinearLayout>

        <LinearLayout
            android:id="@+id/fill3"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />
    </LinearLayout>
</ScrollView>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:gravity="bottom|center_horizontal"
    android:orientation="vertical" >

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxx"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
</LinearLayout>

4

1 に答える 1

0

レイアウトXMLファイルが無効です。XMLを扱うときは、トップレベルのタグを1つだけ持つ必要があります。スクロールビューの下に広告を表示したい場合は、次のようにします。

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:gravity="bottom|center_horizontal"
    android:orientation="vertical" >

    <ScrollView ...>
        <!-- Other pieces under scrollview go here -->
    </ScrollView>

    <com.google.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="xxxxxxxxxxx"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" />
</LinearLayout>

また、スペーサーには、LinearLayoutsではなくViewsのみを使用することをお勧めします。ビューは軽量クラスになり、多くのリソースを使用しなくなります。間隔にLinearLayoutsを使用すると、他の驚きも発生する可能性があります。

于 2012-07-28T15:23:26.563 に答える