2010-09-01 10 views
5

Meine Anzeigen werden nicht angezeigt, ich denke, dass ich die Dokumentation korrekt befolgt habe, sie werden jedoch weiterhin nicht angezeigt. Das Programm ist im Grunde eine Webansicht und ich möchte, dass die Anzeige unten angezeigt wird.Admob-Anzeigen werden nicht angezeigt - Android

Heres mein Layout-Datei:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <WebView 
     android:id="@+id/webview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" /> 
    <com.admob.android.ads.AdView 
     android:id="@+id/ad" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     myapp:backgroundColor="#000000" 
     myapp:primaryTextColor="#FFFFFF" 
     myapp:secondaryTextColor="#CCCCCC" /> 
</LinearLayout> 

Irgendwelche Ideen?

EDIT: Das ist, was ich habe jetzt aber es scheint noch nicht ganz richtig zu sein:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
<com.admob.android.ads.AdView 
    android:id="@+id/ad" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    myapp:backgroundColor="#000000" 
    myapp:primaryTextColor="#FFFFFF" 
    myapp:secondaryTextColor="#CCCCCC" /> 
<WebView 
    android:id="@+id/webview" 
    android:layout_above="@id/ad" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" /> 
</RelativeLayout> 
+0

es sieht Ihr Layout nicht korrekt ist. Ihr Webview nimmt den ganzen Bildschirm ein. versuche, webview und adview zu wechseln und ändere die Höhe der adview auf wrap_content anstelle von fill_parent. – bhups

+0

ein Fehler in 'Admob' kann sein! –

Antwort

6

Ihr Problem ist, dass der WebView auf dem Bildschirm der ganzen Raum nehmen und es gibt keinen Raum Links für die Anzeigen.

Ein LinearLayout verteilt den Speicherplatz nach dem Prinzip "Wer zuerst kommt, mahlt zuerst". Wenn der erste Blick der ganzen Raum wird die zweite Ansicht, keinen Platz bekommen ..

würde ich ein RelativeLayout verwenden und fügen Sie das erste mit einem layout_alignParentBottom Attribute hinzugefügt und anschließend die Webansicht mit einem layout_above="id for the adds" hinzuzufügen. Dies stellt sicher, dass sich die Adds immer am unteren Bildschirmrand befinden, auch wenn der Webview im Moment nicht den gesamten Platz einnimmt und die Webansicht immer über den Adds liegt.

+0

Danke dafür - ich bin auf dem richtigen Weg, aber ich sehe immer noch nicht die Anzeigen - müsste ich die Eltern wechseln? Ich versuche immer noch, Android-Layouts in den Griff zu bekommen, aber danke für die großartige Hilfe. – user319940

+0

Die Anzeigen sollten wrap_content als Höhe und fill_parent als Breite sein, die ich vermute. Das Webview kann fill_parent bleiben. Dies sollte zu einem Layout führen, wo die Adds so groß sind wie sie sein müssen und die Webansicht so groß wie möglich ist. – Janusz

+0

Hmm es scheint immer noch nicht zu funktionieren - nur um zu bestätigen - sieht das alles korrekt aus? (siehe Update) – user319940

0
<?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" 
    android:layout_width="fill_parent" android:id="@+id/rltvLayout1" 
    android:layout_height="fill_parent"> 
    <LinearLayout android:id="@+id/linearLayoutwebview" 
     android:layout_height="wrap_content" android:layout_width="wrap_content" 
     android:orientation="vertical"> 
     <WebView android:id="@+id/webView1" 
      android:layout_width="fill_parent" android:layout_height="fill_parent" 
      android:fitsSystemWindows="true" /> 
    </LinearLayout> 
    <LinearLayout android:layout_width="fill_parent" 
     android:id="@+id/ad_layout" android:layout_height="wrap_content" 
     android:gravity="bottom" android:layout_alignParentBottom="true" 
     android:layout_alignBottom="@+id/home_layout"> 
     <com.google.ads.AdView android:layout_width="wrap_content" 
      android:layout_height="wrap_content" ads:adUnitId="put here your ID" 
      ads:adSize="BANNER" android:id="@+id/adView" ads:refreshInterval="60" /> 

    </LinearLayout> 
</RelativeLayout> 
1

ich hatte das gleiche Problem, fest ich es auf diese Weise: Linearlayout als Hauptlayout Inneres Linearlayout (für die Anzeige) und eine Webansicht, wrap_content auf dem Linearlayout für die Anzeige festgelegt, so, wird es Zeigen Sie zuerst eine Anzeige und dann wird der Rest des Bildschirms die Webansicht sein. Beispiel von mir:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
    <LinearLayout 
android:id="@+id/addmob" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
></LinearLayout> 
<WebView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/webview" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"/> 



</LinearLayout>