1

Android 開発は初めてで、既存のアプリに Admob を追加する方法を学ぼうとしています。Admob SDK の手順を使用して、私が試したいくつかのアプリでこれを成功させることができました。しかし、私の人生では、本来あるべきように画面の一番下に行くことができないというものがあります。main.xml に何かあることは知っていますが、わかりません。

広告ブロックを画面の中央に配置するコードは次のとおりです。

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

<ImageView android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:src="@drawable/eight_ball"
    android:layout_gravity="center_vertical" 
    android:layout_margin="10px" />
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/linearLayout"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center">
        <TextView android:id="@+id/MessageTextView" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:layout_gravity="center" 
            android:background="@drawable/triangle" 
            android:text="@string/shake_me_caption" 
            android:focusable="false" 
            android:gravity="center_vertical|center"
                            android:layout_marginTop="14dip">
        </TextView>
</LinearLayout>
</FrameLayout>

そして、これを扱う私の主な活動 Java ファイルの一部:

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    initialization();
    // Adding AdMob banner
    adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID); 
    LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
    layout.addView(adView); 
    adView.loadAd(new AdRequest());
}

私が言ったように、作業が必要なのは main.xml であると確信しています (おそらくメイン アクティビティのコードにも微調整が必​​要です)。

前もって感謝します。

4

1 に答える 1