我的广告不显示在所有的,我想我已经正确执行了文件,但他们仍然不会显示。该方案基本上是一个web视图,我希望广告显示在底部。
这是我的布局文件:
< XML版本=1.0编码=UTF-8&GT?;
<的LinearLayout
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:的myapp =http://schemas.android.com/apk/res/man.utd.headlines
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
<的WebView
机器人:ID =@ + ID / web视图
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT/>
< com.admob.android.ads.AdView
机器人:ID =@ + ID /广告
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
的myapp:的backgroundColor =#000000
的myapp:primaryTextColor =#FFFFFF
的myapp:secondaryTextColor =#CCCCCC/>
< / LinearLayout中>
任何想法?
编辑:这是我现在,但它仍然没有出现是相当正确的:
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的
的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:的myapp =http://schemas.android.com/apk/res/man.utd.headlines
机器人:方向=垂直
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT>
< com.admob.android.ads.AdView
机器人:ID =@ + ID /广告
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentBottom =真
的myapp:的backgroundColor =#000000
的myapp:primaryTextColor =#FFFFFF
的myapp:secondaryTextColor =#CCCCCC/>
<的WebView
机器人:ID =@ + ID / web视图
机器人:layout_above =@ ID /广告
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT/>
< / RelativeLayout的>
解决方案
您的问题是,web视图将在屏幕上的所有空间,没有空间留给广告。
一个的LinearLayout会分配空间上的先到先得的规则。如果第一次查看通吃空间第二种观点不会得到任何空间。
我会用一个RelativeLayout并添加第一个加了 layout_alignParentBottom
属性,然后用添加的WebView一个 layout_above =ID为将
。这将确保ADDS总是在屏幕的底部,即使web视图不会采取目前所有的空间和web视图将总是高于ADDS
My ads don't display at all, I think I've followed the documentation correctly but they still won't show. The program is basically a webview and I want the ad to display at the bottom.
Heres my layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id="@+id/webview"
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="fill_parent"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC" />
</LinearLayout>
Any ideas?
EDIT: this is what I now have but it still doesn't appear to be quite right:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/man.utd.headlines"
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"
android:layout_alignParentBottom="true"
myapp:backgroundColor="#000000"
myapp:primaryTextColor="#FFFFFF"
myapp:secondaryTextColor="#CCCCCC" />
<WebView
android:id="@+id/webview"
android:layout_above="@id/ad"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</RelativeLayout>
解决方案
Your Problem is that the WebView will take all the space on the screen and there is no space left for the ads.
A LinearLayout will distribute the space on a first come first serve rule. If the first View takes all the space the second view won't get any space..
I would use a RelativeLayout and add the adds first with a layout_alignParentBottom
attribute and then add the webview with a layout_above="id for the adds"
. This will ensure that the adds are always on the bottom of the screen even if the webview wont take all the space at the moment and the webview will always be above the adds.