2

私はAndroidプロジェクトに取り組んでおり、AdMobsDKの最新バージョンをダウンロードしました。

画面の下部に広告を配置しようとしていますが、何も機能しないようです。

以下はレイアウトのXMLコードです

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView android:id="@+id/password_noRecords"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center"
        android:text="There are currently\nno saved logins"
        android:textSize="20dp"
        android:textStyle="bold|italic"/>
    <ListView 
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
    </ListView>
        <com.google.ads.AdView android:id="@+id/adView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            ads:adUnitId="MY_ID"
            ads:adSize="BANNER"
            ads:testDevices="TEST_EMULATOR, emulator-5554"
            ads:loadAdOnCreate="true">
        </com.google.ads.AdView>
</LinearLayout>

高さでListViewとLinearLayoutfill_parentを作成しようとしましたが、logcatには、広告を表示するのに十分なスペースがないと表示されます。

また、広告を線形レイアウトでラップして、親の下部を揃える= trueと言ってみましたが、違いはありません。

代わりに、広告はリストビューの下部に直接配置されるため、リストビューが半分空の場合、広告は画面の中央に表示されます。

私が欲しいのは、リストビューがどんなに大きくても小さくても、画面の下部に常に表示される広告です。

あなたが提供できるどんな助けにも感謝します。

4

2 に答える 2

12

親のレイアウトをに変更しますRelativeLayout

android:layout_alignParentBottom="true"adViewとListViewで使用しandroid:layout_above="@+id/adView"ます。

必要に応じて残りのビューを使用android:layout_below="@+id/xxxx"して、ビューが自分のビューと同じように動作するようにしますLinearLayout

于 2012-06-30T15:27:44.310 に答える
-2

.xmlファイルの[デザイン]タブを使用して広告を配置する必要がある場合があります。余白などを調整します...

于 2017-07-02T03:15:06.140 に答える