如何使AdMob广告显示在屏幕顶部?

| 我已经在我的应用程序中使用了AdMob,但它显示在屏幕底部。有人知道如何将其强制显示在屏幕顶部吗?我不想使用RelativeLayout,因为我的LinearLayout已经设置了很多东西。 我正在通过main.xml中的@id引用以及Java活动中的一些调用来启动AdMob:
<?xml version=\"1.0\" encoding=\"utf-8\"?>

<ScrollView
    xmlns:android=\"http://schemas.android.com/apk/res/android\"
    android:layout_width=\"fill_parent\"
    android:layout_height=\"fill_parent\">

    <LinearLayout
         android:id=\"@+id/linearLayout\"   .....this is the only line I added for my Admob reference
         android:orientation=\"vertical\"
         android:layout_width=\"fill_parent\"
         android:layout_height=\"fill_parent\"
         >

    <LinearLayout
    android:orientation=\"horizontal\"
    android:layout_width=\"fill_parent\"
    android:layout_height=\"fill_parent\"
    android:gravity=\"center\">

    <ImageView android:id=\"@+id/ImageView01\"
        android:src=\"@drawable/image01\"
        android:layout_height=\"150dp\"
        android:layout_width=\"200dp\"
        android:scaleType=\"centerCrop\"
        android:paddingTop=\"10px\">
    </ImageView>

    </LinearLayout>
           ....
然后我的java活动中有这个...
    setContentView(R.layout.main);

    //create an adView
    LinearLayout layout = (LinearLayout)findViewById(R.id.linearLayout);
    String pubID = \"a14d9cfd23d60cf\";
    AdView adView = new AdView(this, AdSize.BANNER, pubID);
    layout.addView(adView);
    AdRequest request = new AdRequest();

    //request.setTesting(true);
    adView.loadAd(request);
编辑..解决方案....... 没关系...我明白了。这与放置布局ID的位置有关。如果我现在将android:id = \“ @ + id / linearLayout \”下移到LinearLayout的正下方,则其广告会显示在顶部。     
已邀请:
解决此问题的一种方法是将广告视图放入XML。您所做的就是,将其与其他任何视图一样放置在根目录LinearLayout下的视图层次结构顶部。换句话说,您将获得以下内容:
<LinearLayout
android:id=\"@+id/linearLayout\"   .....this is the only line I added for my Admob reference
android:orientation=\"vertical\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
>
  <com.google.ads.AdView android:id=\"@+id/adView\"
                         android:layout_width=\"wrap_content\"
                         android:layout_height=\"wrap_content\"
                         ads:adUnitId=\"MY_AD_UNIT_ID\"
                         ads:adSize=\"BANNER\"/>
    <LinearLayout
    android:orientation=\"horizontal\"
    android:layout_width=\"fill_parent\"
    android:layout_height=\"fill_parent\"
    android:gravity=\"center\">

    <ImageView android:id=\"@+id/ImageView01\"
        android:src=\"@drawable/image01\"
        android:layout_height=\"150dp\"
        android:layout_width=\"200dp\"
        android:scaleType=\"centerCrop\"
        android:paddingTop=\"10px\">
    </ImageView>

    </LinearLayout>
查看http://code.google.com/mobile/ads/docs/android/banner_xml.html,以获取更多信息。     

要回复问题请先登录注册