1

私のアクティビティでは、広告ビューは画面の下部に表示されますが、サイズを変更するのではなく、メイン コンテンツと重なっています。これを達成する方法は?

このガイドに従いました。

XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <LinearLayout
        android:id="@+id/contentsLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >

        <ListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </ListView>
    </LinearLayout>


    <LinearLayout
        android:id="@+id/adLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/contentsLayout"
        android:layout_alignParentBottom="true"
        android:gravity="bottom|center"
        android:orientation="horizontal" >
    </LinearLayout>

</RelativeLayout>
4

1 に答える 1

2

コンテンツ レイアウトを adView の上に配置します。また、次のように XML を並べ替える必要があります。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <LinearLayout
        android:id="@+id/adLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="bottom|center"
        android:orientation="horizontal" >
    </LinearLayout>

    <LinearLayout
        android:id="@+id/contentsLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_above="@id/adLayout"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin" >

        <ListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
        </ListView>
    </LinearLayout>

</RelativeLayout>

コンテンツがandroid:layout_above="@id\adLayout"adLayout の下に入ることはありません。adLayout の id を定義して使用する必要があるため、xml を並べ替える必要があります。layout_above

android:layout_alignBottom="@+id/contentsLayout"adLayout からも削除 します

于 2013-07-21T10:48:42.253 に答える