use*_*940 5 android webview admob
我的广告根本没有显示,我想我已经正确地遵循了文档,但它们仍然无法显示.该程序基本上是一个webview,我希望广告显示在底部.
继承我的布局文件:
<?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>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
编辑:这是我现在拥有的,但它似乎仍然不是很正确:
<?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>
Run Code Online (Sandbox Code Playgroud)
您的问题是WebView将占用屏幕上的所有空间,并且广告没有剩余空间.
LinearLayout将在先来先服务规则上分配空间.如果第一个视图占用了所有空间,则第二个视图将不会获得任何空间.
我会使用RelativeLayout并首先添加一个layout_alignParentBottom属性添加,然后添加一个webview layout_above="id for the adds".这将确保添加始终位于屏幕底部,即使webview目前不占用所有空间并且webview将始终位于添加之上.
| 归档时间: |
|
| 查看次数: |
9614 次 |
| 最近记录: |