如何使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的正下方,则其广告会显示在顶部。
没有找到相关结果
已邀请:
1 个回复
素汞读
查看http://code.google.com/mobile/ads/docs/android/banner_xml.html,以获取更多信息。