6

私はgogoleAdviewをリストの一番下と中央に揃えようとしていますが、これまでは、リストに干渉することなくAdviewをリストの一番下に表示することができましたが、中央に表示されません。

コードは下に貼り付けられています。スクリーンショットを添付しないでください。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/topLayout"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/linearlayoutlistview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/ad_holder"
        android:orientation="vertical" >

        <ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dip"
            android:drawablePadding="4dip"
            android:paddingTop="2dip"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textStyle="bold"
            android:typeface="serif" >
        </ListView>
    </LinearLayout>

    <!-- Ad Placeholder -->

    <LinearLayout
        android:id="@+id/ad_holder"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="bottom" >

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

    </LinearLayout>

</RelativeLayout>
4

4 に答える 4

10

LinearLayoutAdView の親として使用しないでください。代わりに、AdView にRelativeLayoutandを使用します。layout_centerInParent="true"

<RelativeLayout
    android:id="@+id/ad_holder"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:gravity="bottom" >

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

</RelativeLayout>
于 2012-04-13T15:05:33.373 に答える
5

またはandroid:layout_width="fill_parent"、引き続き使用したい場合にのみ使用してくださいLinearLayout

于 2014-06-04T13:00:57.790 に答える
1

使用 android:layout_alignParentBottom="true"してandroid:layout_centerHorizontal="true"

于 2012-04-13T15:05:07.977 に答える