屏幕的Andr​​oid AdMob的位置上方不工作 [英] Android AdMob Position top of screen not working

查看:271
本文介绍了屏幕的Andr​​oid AdMob的位置上方不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想AdMob的融入我的Andr​​oid应用程序,并且可以使用默认的样本布局code在屏幕底部的位置AdMob的时候得到它在模拟器上正常工作,但每当我试图位置它向屏幕没有广告获得服务的顶部。我已阅读,这或许是由于缺乏对广告空间。

I am trying to integrate AdMob into my Android Application, and can get it to work fine in the simulator when using the default sample layout code to position AdMob at the bottom of the screen, however whenever I try to position it to the top of the screen no adverts get served. I have read that this could perhaps be due to lack of space for the adverts.

这code工作在屏幕的底部(纵向):

This code works at the bottom of the screen (portrait):

<RelativeLayout 
    android:id="@+id/InnerRelativeLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" >

   <com.admob.android.ads.AdView
      android:id="@+id/ad" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"
      app:backgroundColor="#000000"
      app:primaryTextColor="#FFFFFF"
      app:secondaryTextColor="#CCCCCC"
      android:layout_alignParentBottom="true"
    />

</RelativeLayout>

但是当我尝试在顶部放置它不工作

But when I try to position it at the top it does not work

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget40"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.myapp.xxxx"
>

<RelativeLayout 
        android:id="@+id/InnerRelativeLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" >

       <com.admob.android.ads.AdView
          android:id="@+id/ad" 
          android:layout_width="fill_parent" 
          android:layout_height="wrap_content"
          app:backgroundColor="#000000"
          app:primaryTextColor="#FFFFFF"
          app:secondaryTextColor="#CCCCCC"
          android:layout_alignParentTop="true"
        />
    </RelativeLayout>

<TextView
    android:id="@+id/widget28"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Input Amount:"
    android:layout_marginLeft="10dip"
    android:layout_marginTop="10dip"
    android:layout_marginRight="10dip"
    android:textSize="16dip"
    android:textStyle="bold">
</TextView>

任何帮助将是AP preciated。

Any help would be appreciated.

由于阿龙

推荐答案

如果你总是想显示在屏幕的上方,那么你可能要考虑使用RelativeLayout的。

If you always want to display on top of the screen then you may want to consider using RelativeLayout.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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"
      app:backgroundColor="#000000"
      app:primaryTextColor="#FFFFFF"
      app:secondaryTextColor="#CCCCCC"
      android:layout_alignParentTop="true"
    />

<!-- TextView below that -->

<TextView
android:id="@+id/widget28"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Input Amount:"
android:layout_marginLeft="10dip"
android:layout_marginTop="10dip"
android:layout_marginRight="10dip"
android:layout_below="@id/ad"
android:textSize="16dip"
android:textStyle="bold">
</TextView>

</RelativeLayout>

这篇关于屏幕的Andr​​oid AdMob的位置上方不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆