0
我的admob廣告和緊接着它的下一張圖片之間存在差距。爲什麼?差距與廣告大致相同。下面是我的XML:爲什麼我的admob廣告之後會有差距?
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:gravity="center_horizontal"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:orientation="horizontal" >
</LinearLayout>
<LinearLayout
android:id="@+id/companylogo"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
android:background="@drawable/hotluxa"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/kisstabutton"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:src="@drawable/clear" />
</LinearLayout>
<LinearLayout
android:id="@+id/vehicletype"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.5"
android:orientation="vertical" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/corvetteconvertible"
android:src="@drawable/clear" />
</LinearLayout>
<LinearLayout
android:id="@+id/soundoptions"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.12"
android:orientation="horizontal">
<ImageButton
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/greenbubble"
android:src="@drawable/clear" />
</LinearLayout>
<ImageButton
android:id="@+id/imageButton6"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.12"
android:background="@drawable/fullversion"
android:src="@drawable/clear" />
</LinearLayout>
和我的Java文件(摘錄): super.onCreate(savedInstanceState); setContentView(R.layout.mainxml); Log.e(「main」,「mainxml loaded ok」);
// Create the adView
adView = new AdView(this, AdSize.BANNER, "a1509a21e11b5e1");
// Lookup your LinearLayout assuming it's been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout) findViewById(R.id.linearad);
Log.e("main", "1");
// Add the adView to it
layout.addView(adView);
Log.e("main", "2");
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest();
adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
Log.e("main", "3");
// Initiate a generic request to load it with an ad - should be when finished: adView.loadAd(new AdRequest());
adView.loadAd(adRequest);
發佈完整的XML。 –
發佈您要添加廣告的代碼 – jcw
它可能與您的佈局權重有關。嘗試給'linearad'容器50dp高度。 –