Android AdMob not showing LinearLayout on Bottom(Android AdMob 未在底部显示 LinearLayout)
问题描述
好吧,AdMob 的情况真的很奇怪.我想将广告放在底部我有一个 LinearLayout.当我这样做时,它永远不会出现.当我把它放在上面时,它完美地显示出来.不知道这里的交易是我的代码.我确实在 LogCat 中收到一条警告,上面写着没有足够的空间来展示广告!想要 <480,75> 有:<480, 0>"
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>
还有我的 onCreate():
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
推荐答案
我的猜测是您的列表视图填满了屏幕并且正在向下推广告视图.试试这个 xml 的列表视图:
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android AdMob 未在底部显示 LinearLayout
基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01