首页 > 解决方案 > 如何在相对布局中设置带有 web 视图的广告而不重叠?

问题描述

在此布局中,Google 广告与 web 视图重叠。这就是 Google Admob 警告我的原因。我希望广告显示在 web 视图的末尾。我要怎么做?

我尝试这样做,但做不到。有人可以帮助我吗?我需要修复它......我尝试这样做,但无法做到。有人可以帮助我吗?我需要修复它......

?xml version="1.0" encoding="utf-8"

<RelativeLayout

xmlns:android=

"http://schemas.android.com/apk/res/android"

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout width="match parent"

android:layout height="match parent"

tools:context=".TeamInfo.Team1">



<com.github.ybq.android.spinkit.SpinKitView

android:id="@+id/spin kit"

style="@style/SpinKitView.Large.Circle"

android:layout width="wrap content"

android:layout height="wrap content"

android:layout gravity="center"

app:SpinKit Color="#E53935"

android:layout centerInParent="true"/>





<ImageView

android:id="@+id/teamimage1"

android:layout width="match parent"

android:layout height="match parent"

android:background="@drawable/commoninfo"

android:visibility="gone"/>



<WebView

android:id="@+id/team1web"

android:layout width="match parent"

android:layout height="match parent"

android:visibility="gone">

</WebView>





!—Google Admob Link—&gt;

<com.google.android.gms.ads.AdView

android:id="@+id/banner container1"

android:layout width="wrap content"

android:layout height="wrap content"

android:layout alignParentBottom="true"

android:layout centerHorizontal="true"

app:adSize="BANNER"

app:adUnitId="@string/ad id">

</com.google.android.gms.ads.AdView>









</RelativeLayout>





<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".TeamInfo.Team1">

    <com.github.ybq.android.spinkit.SpinKitView
        android:id="@+id/spin_kit"
        style="@style/SpinKitView.Large.Circle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:SpinKit_Color="#E53935"
        android:layout_centerInParent="true"/>


    <ImageView
        android:id="@+id/teamimage1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/commoninfo"
        android:visibility="gone"/>

    <WebView
        android:id="@+id/team1web"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">
    </WebView>


    <!--Google Admob Code-->
    <com.google.android.gms.ads.AdView
            android:id="@+id/banner_container1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            app:adSize="BANNER"
            app:adUnitId="@string/ad_id">
    </com.google.android.gms.ads.AdView>




</RelativeLayout>

标签: androidandroid-studioandroid-layoutadmobandroid-relativelayout

解决方案


在您的网络视图中添加此行

        android:layout_above="@id/banner_container1"

下面的最终代码

<WebView
        android:id="@+id/team1web"
        android:layout_above="@id/banner_container1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="visible">
</WebView>

推荐阅读