Comment puis-je faire SMART_BANNER annonces de admob remplir correctement dans Android?
J'ai une smart bannière au bas de mon portrait app.
Ma mise en page ressemble à ceci:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp">
<TextSwitcher
...
Some TextSwitcher Stuff Here
... />
<com.google.ads.AdView
xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/bannerAd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:visibility="visible"
googleads:adSize="SMART_BANNER"
googleads:adUnitId="@string/admobId" />
</RelativeLayout>
Mon Manifeste dispose des autorisations appropriées et ce:
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
</activity>
Et mes annonces sont initialisées par le présent code:
private void initialiseAds()
{
AdView adView = (AdView) findViewById(R.id.bannerAd);
adView.setAdListener(new MyAdListener(adView));
AdRequest adRequest = new AdRequest();
adRequest.addKeyword("games");
adRequest.addKeyword("tabletop games");
adRequest.addKeyword("board games");
adRequest.addKeyword("monopoly");
adRequest.addKeyword("gambling");
adRequest.addKeyword("dice");
final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
String deviceId = tm.getDeviceId();
adRequest.addTestDevice(deviceId);
adView.loadAd(adRequest);
}
Quand je lance l'application, mes annonces ne s'affichent pas. LogCat me donne ceci:
08-01 11:24:59.015: E/Ads(10436): Not enough space to show ad! Wants: <720, 100>, Has: <656, 935>
08-01 11:24:59.020: E/Ads(10436): Not enough space to show ad! Wants: <720, 100>, Has: <656, 935>
L'appareil est un Galaxy S3. Il semble obtenir les exigences de taille de mal ((720, 100) est certainement trop grand pour un téléphone bannière application?).
La SMART_BANNER est déclaré en XML, donc je ne peux pas croire le AdView doit être régénéré incode, car il doit déjà savoir les tailles sur la première instanciation?
Des idées?
EDIT:
Si j'ai mis SMART_BANNER à l'intérieur seulement les plus extérieures de la Mise en page, c'est le XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity" >
<Button
android:id="@+id/btnRollDice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:contentDescription="@string/buttonDescription"
android:onClick="rollDice"
android:text="@string/btnRoll"
android:textSize="40sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp">
<TextSwitcher
android:id="@+id/diceValue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:animateFirstView="false"
android:contentDescription="@string/textSwitcherDescription"
android:inAnimation="@anim/slide_down"
android:outAnimation="@anim/abc_fade_out"
android:textAlignment="center"
android:visibility="visible" />
</RelativeLayout>
<com.google.ads.AdView
android:id="@+id/bannerAd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="0dp"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/admobId"
android:gravity="bottom"
android:padding="0dp"
android:visibility="visible" />
</LinearLayout>
Et c'est le Message d'Erreur:
08-01 12:59:38.120: E/Ads(22919): Not enough space to show ad! Wants: <720, 100>, Has: <720, 0>
Je soupçonne que c'est parce que le RelativeLayout et Bouton ont rempli le LinearLayout et n'a pas laissé de place pour le AdView. Est-il possible d'attribuer un wrap_contents vaut la peine de hauteur à adview sans impact sur le RelativeLayout?
Edit: Solution:
Ce point de vue est d'environ 95% de la façon dont il (assez bon 🙂 ). Le TextSwitcher est d'environ 1% off dead center et il a légèrement plafonné à hauteur de mais vous n'avez pas vraiment d'avis, à moins que vous regardé et comparé pendant des heures. J'espère que cela aidera quelqu'un. Grâce à Harshid et William pour les contributions.
<!-- This is the XML for the Portrait View of the App
It has 2 major tiers
The first tier contains 3 items:
The Ad Banner
The button
The 2nd Tier
The second tier contains 1 item
The TextSwitcher
XML is pretty readable so just read it! :)
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity"
android:id="@+id/masterContainer">
<com.google.ads.AdView
android:id="@+id/bannerAd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="0dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/admobId"
android:padding="0dp"
android:visibility="visible" />
<Button
android:id="@+id/btnRollDice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginBottom="0dp"
android:paddingBottom="0dp"
android:contentDescription="@string/buttonDescription"
android:onClick="rollDice"
android:text="@string/btnRoll"
android:textSize="40sp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/bannerAd"
android:layout_below="@id/btnRollDice"
android:layout_margin="0dp"
android:orientation="vertical"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp" >
<TextSwitcher
android:id="@+id/diceValue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentLeft="false"
android:layout_alignParentRight="false"
android:layout_alignParentTop="false"
android:layout_centerHorizontal="false"
android:layout_centerInParent="true"
android:layout_centerVertical="false"
android:layout_gravity="center"
android:animateFirstView="false"
android:contentDescription="@string/textSwitcherDescription"
android:inAnimation="@anim/slide_down"
android:outAnimation="@anim/abc_fade_out"
android:textAlignment="center"
android:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
OriginalL'auteur BigTobster | 2013-08-01
Vous devez vous connecter pour publier un commentaire.
Je Pense que votre
Admob banner
est dans la Mise en page.Mettre des bannières hors côté de toute la Présentation et interne sur la page Principale.Parce que vous avez utilisé rembourrage,de la Marge et du bla Bla..
essayer cette.
Mieux, mais pas encore assez. La bannière s'affiche maintenant parfaitement (Bien fait!). mais le conteneur est wrap_content de sorte qu'il remplit le reste de la page (car un smart_banner pourrait être de n'importe quelle hauteur assumably). Cela signifie que le contenu est poussé hors du centre de la page. La seule façon de contourner ce que je peux penser à est de retourner à la case 1 et de placer les éléments à l'intérieur la mise en page!
Malheureusement, votre réponse n'est pas utilisable pour mon problème. J'ai essayé de bidouiller mais il au sérieux n'ira pas ensemble (je suis un noob). Je vais accepter votre réponse sur le motif qu'il pourrait travailler pour quelqu'un d'autre qui n'a pas le même set-up que je fais. Merci pour votre aide.
OriginalL'auteur Harshid
De s'assurer que votre externe de la mise en page n'a pas de rembourrage
OriginalL'auteur Hevski
Si vous souhaitez utiliser votre deuxième mise en page, alors vous devriez donner la relative mise en page d'un layout_weight de 1 (layout_weight seulement,s'applique à LinearLayouts). Cela indiquera à s'étendre à remplir tout l'espace inutilisé dans le contenant LinearLayout.
Vous suggère de lire http://developer.android.com/guide/topics/ui/declaring-layout.html pour obtenir une meilleure compréhension de Android mises en page, vous êtes à l'aide d'attributs de RelativeLayout et LinearLayout tort et à travers. Certains des attributs de mise en page sont uniquement applicables à un type de mise en page.
OriginalL'auteur William
Vérifiez votre appareil dp et de la charge à l'aide de divers ad constantes(bannière, classement, etc) avec la touche respective donnée dans admob médiation.
OriginalL'auteur zelva
À partir de votre Code XML, Retirez les Quatre Rembourrage Attributs c'est à dire, PaddingBottom, PaddingLeft, PaddingRight, PaddingTop
OriginalL'auteur zackygaurav