0

ボタンがほとんどないAndroidアプリのレイアウトがあります。ページの下部に広告を設定しようとしています。以下の私のレイアウトを参照してください。

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/MainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_color"
    android:gravity="center_horizontal"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_top_margin" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView0"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="left|center_vertical"
                android:text=""
                android:textColor="@color/text_color"
                android:textSize="@dimen/nav_text_size" >
            </TextView>

            <Button
                android:id="@+id/ProceedToScreen31"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawableRight="@drawable/ic_action_name"
                android:gravity="left|center_vertical"
                android:text="@string/TA1"
                android:textColor="@color/btn_text_color"
                android:textSize="@dimen/button_text_size" >
            </Button>

            <Button
                android:id="@+id/ProceedToScreen32"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawableRight="@drawable/ic_action_name"
                android:gravity="left|center_vertical"
                android:text="@string/TA2"
                android:textColor="@color/btn_text_color"
                android:textSize="@dimen/button_text_size" >
            </Button>

            <Button
                android:id="@+id/ProceedToScreen33"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawableRight="@drawable/ic_action_name"
                android:gravity="left|center_vertical"
                android:text="@string/TA3"
                android:textColor="@color/btn_text_color"
                android:textSize="@dimen/button_text_size" >
            </Button>

            <Button
                android:id="@+id/ProceedToScreen34"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawableRight="@drawable/ic_action_name"
                android:gravity="left|center_vertical"
                android:text="@string/TA4"
                android:textColor="@color/btn_text_color"
                android:textSize="@dimen/button_text_size" >
            </Button>

            <View
                android:layout_width="match_parent"
                android:layout_height="2dip"
                android:background="@color/line_color" >
            </View>

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/copyright"
                android:textColor="@color/text_color"
                android:textSize="@dimen/small_text_size" >
            </TextView>
        </LinearLayout>
    </ScrollView>

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

</RelativeLayout>

広告は固定フッターとしてページの下部に完全に表示されます (私の要件による) が、ページの他のコンポーネントもページの下部に表示され、ページの上部に大きなスペースが残ります。助けてください 広告のみがページの下部に来るように配置するにはどうすればよいですか。残りのすべてのコンポーネントはページの上部から開始する必要があります。

4

4 に答える 4

0

削除してみてください

android:gravity="center_horizontal"

上のレイアウトから。実際、個人的に適切な場所に物事が収まるまで、重力に関するすべての言及を削除します。また、あなたはどのくらいの大きさをチェックしたいかもしれません

@dimen/activity_top_margin

は。それはあなたが持っているスペースをうまく説明するかもしれません.

于 2013-04-12T19:37:17.170 に答える
0

これは、スクロール ビューの次の行が原因です。

android:layout_above="@+id/adView"

基本的に「 adView のすぐ上に、ScrollView を配置してください」と言っているからです。それを削除するだけで修正されました。

于 2013-04-12T19:25:36.973 に答える
0

ScrollView->に追加するとandroid:layout_alignParentTop="true"、上部の空白が削除されます。

さらに、AdView最初に を設定してからScrollViewwithを設定することをお勧めします。これは、レイアウトを に応じて設定し、他のレイアウトに依存しないレイアウトを最初に定義してから、他のレイアウトを定義する必要がある場合があるためです。android:layout_above="@+id/adView"ScrollViewAdView

于 2013-04-12T20:03:44.433 に答える
0

入力していただきありがとうございます。私のコードに問題がありました。Java クラスと XML ファイルの両方で Ad を設定していました。Java で Ad コードを削除し、ここの提案に従って XML ファイルのコードを少し変更しました。 android:layout_above="@+id/adView"

これで、すべてが要件どおりに正常に表示されます。お時間とご意見をお寄せいただきありがとうございます。

于 2013-04-17T11:36:26.907 に答える