2012-01-23 13 views
0

ページが表示されているときにAndroid画面がシフトしないようにするにはどうすればよいですか?AdViewで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> 

TIA、トレイ・

答えて

0

私は広告で多くの経験を持っていません。しかし、Viewの観点から見ると、adViewがロードされる前にView.GONEに設定されているように見えます。これは、他のビューを親に配置するときにその空間が無視されることを意味します。

私はあなたがそれをやり遂げない方法を知ることはできません。しかし、明示的にxmlのandroid:visibility="invisible"に設定してみると、あなたのJavaでは読み込んだ後に可視にする必要があります。 「見えない」というのは消えたようなものですが、目に見えるときにあなたが取り上げる空間を尊重するよう親に指示します。

おそらくloadOnCreate属性は、表示されている動作を引き起こしますか?それを使わずに試してみて、onCreateで手動で読み込む価値があるかもしれません。

関連する問題