0

ページが表示され、最初の追加を受け取ったときに Android 画面が下に移動しないようにするにはどうすればよいですか?

ビューが最初に表示されるときは通常の画面ですが、次に広告が表示され、画面が数行下に移動します。

これが私のコードです。

<?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:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background3"
android:orientation="vertical" >

<com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="2dp"
    android:layout_gravity="top"
    ads:adSize="BANNER"
    ads:adUnitId="xxxxxxxxxx"
    android:gravity="center"
    ads:loadAdOnCreate="true" >
</com.google.ads.AdView>

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="fill_parent"
    android:layout_height="50dp"
    android:layout_marginTop="34dp" >

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="3"
        android:text="Start" />

</TableRow>

</LinearLayout>

ティア、トレイ

4

1 に答える 1

0

I don't have much experience with the ads. But from strictly a View standpoint it seems like what is happening is that the adView is set to View.GONE before it loads. Which means that its space is ignored when placing the other views into the parent.

I don't know for sure how you could get it to not do that. But I would try explicitly setting it to android:visibility="invisible" in your xml, then in your java you'll have to make it visible after it has loaded. "invisible" is like gone, but it tells the parent to respect the space that you will take up when you are visible.

Perhaps the loadOnCreate attribute causes the behavior you are seeing? Might also be worth trying it without that and just load it manually in your onCreate.

于 2012-01-23T16:08:46.193 に答える