0

広告バナーを画面の下部に配置しようとしています。ただし、広告の一部が上部に表示され、他の部分が下部に表示されます。下の画像を見てください

間違った広告 http://img513.imageshack.us/img513/4390/shot000025.png

以下は、それが役立つ場合のコードです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/maingradient"
    android:focusableInTouchMode="true"
    android:orientation="vertical" >

    <RelativeLayout
    android:id="@+id/relativelayout2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/relativeLayout1" >

    <ListView
        android:id="@android:id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:cacheColorHint="@android:color/transparent"
        android:divider="#00ff00"
        android:fastScrollEnabled="true"
        android:focusable="false"
        android:listSelector="#000000"
        android:paddingTop="5dp"
        android:saveEnabled="true" >

    </ListView>
    </RelativeLayout>


    <com.google.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/adView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    ads:adSize="SMART_BANNER"
    android:layout_alignParentBottom="true"
    ads:adUnitId="a14fd64cddd4168"
    ads:loadAdOnCreate="true" />

</RelativeLayout>

誰か助けてくれませんか?

どうも!ラフル。

4

2 に答える 2

1

正確な問題が何であるかはわかりませんが、レイアウトにいくつかの問題があります。まず、別の RelativeLayout 内にネストされた RelativeLayout がありますが、それを親に含まれていない 3 番目の相対レイアウトの下に配置しようとしていますか? また、ファイルのルート RelativeLayout にandroid:orientationは LinearLayouts 用の属性があります。それはすべて少し混乱しています。

解決策として、ルートの RelativeLayout を LinearLayout にして、垂直方向を維持してみてください。android:layout_heightネストされた RelativeLayout にof0dipandroid:layout_weightofを与えることができます1(そして属性を取り除きlayout_belowます。なぜそこにあるのかわかりません)。これにより、ListView が広告の上に配置され、広告が占めていないすべてのスペースが埋められます。お役に立てれば。

于 2012-07-13T20:08:00.603 に答える
0

次のコードを試してください

 <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@android:color/black" >


<com.google.ads.AdView
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="50dp"
ads:adSize="SMART_BANNER"
android:layout_alignParentBottom="true"
ads:adUnitId="a14fd64cddd4168"
ads:loadAdOnCreate="true" />


  <ListView
    android:id="@+id/show_locations_list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/black"
    android:layout_above="@+id/adView"
    android:scrollbars="none"
    android:scrollingCache="false" >
</ListView>

それが役に立てば幸い

于 2012-07-13T19:36:38.210 に答える