Android的AdMob广告没有显示在底部的LinearLayout [英] Android AdMob not showing LinearLayout on Bottom
问题描述
好了很奇怪的情况与AdMob的。我要放置广告的底部我有一个LinearLayout中。当我做它永远不会显示出来。当我把它放到最上面它显示了完美。不知道什么问题就在这里是我的code。我得到的LogCat中一个警告,表示没有足够的空间来显示广告想< 480,75>有:< 480,0>
的LinearLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:广告=http://schemas.android.com/apk/res/mypackage
机器人:ID =@ + ID / mainmenulayout
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
< ImageView的机器人:ID =@ + ID / headerpic
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:SRC =@可绘制/头/>
< ListView的机器人:ID =@机器人:ID /列表
机器人:分隔=#00000000
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:drawSelectorOnTop =假
机器人:背景=@机器人:彩色/透明
机器人:cacheColorHint =#00000000
机器人:layout_alignParentTop =真正的>
< / ListView控件>
< com.google.ads.AdView
机器人:ID =@ + ID / AD浏览报
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
广告:adUnitId =myadunit
广告:adSize =大旗
/>
< / LinearLayout中>
和我的onCreate():
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.appmenu);
//查找AD浏览报作为一种资源和负载的请求。
AD浏览报AD浏览报=(AD浏览报)this.findViewById(R.id.adView);
adView.loadAd(新AdRequest());
的String [] mainMenuList = getResources()getStringArray(R.array.mainMenuList)。
。TypedArray [] picFiles = getResources()obtainTypedArray(R.array.arrayIcon);
setListAdapter(新MyIconAdapter(mainMenuList,picFiles));
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} //关闭的onCreate
我的猜测是,你的列表视图填满整个屏幕,并推下来AD浏览。试试这个XML列表视图:
< ListView的机器人:ID =@机器人:ID /列表
机器人:分隔=#00000000
机器人:layout_width =FILL_PARENT
机器人:layout_height =0px
机器人:layout_weight =1
机器人:drawSelectorOnTop =假
机器人:背景=@机器人:彩色/透明
机器人:cacheColorHint =#00000000
机器人:layout_alignParentTop =真正的>
< / ListView控件>
这将使列表视图只之多房地产作为可用后的图像查看和广告观要求他们的份额。
Okay really weird situation with AdMob. I want to place the ad on the bottom I have a LinearLayout. When I do it never shows up. When I place it on top it shows up perfectly. Not sure what the deal is here is my code. I do get a warning in LogCat that says "Not enough space to show ad! Wants <480,75> Has: <480, 0>"
LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res/mypackage"
android:id="@+id/mainmenulayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/headerpic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/header"/>
<ListView android:id="@android:id/list"
android:divider="#00000000"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:background="@android:color/transparent"
android:cacheColorHint="#00000000"
android:layout_alignParentTop="true">
</ListView>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="myadunit"
ads:adSize="BANNER"
/>
</LinearLayout>
and my onCreate():
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.appmenu);
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());
String[] mainMenuList = getResources().getStringArray(R.array.mainMenuList);
TypedArray[] picFiles = getResources().obtainTypedArray(R.array.arrayIcon);
setListAdapter(new MyIconAdapter(mainMenuList, picFiles));
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} //close onCreate
My guess is that your list view fills the screen and is pushing the adview down. Try this xml for the list view:
<ListView android:id="@android:id/list"
android:divider="#00000000"
android:layout_width="fill_parent"
android:layout_height="0px"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:background="@android:color/transparent"
android:cacheColorHint="#00000000"
android:layout_alignParentTop="true">
</ListView>
This will give the list view only as much real estate as is available after the image view and ad view claim their share.
这篇关于Android的AdMob广告没有显示在底部的LinearLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!