首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何正确地在底部使用webview进行广告投放?

如何正确地在底部使用webview进行广告投放?
EN

Stack Overflow用户
提问于 2021-08-16 09:38:42
回答 2查看 28关注 0票数 0

我想把广告放在这个WebView的末尾..

但是当我把它放在WebView下面时,它没有显示出来。如果我把它放在WebView上面,我会像附件一样显示...

我尝试更改宽度和高度,但它也不起作用!这就是为什么我的Facebook观众会给我一个警告,说你的广告投放是错误的。我怎么才能修复它呢?

代码语言:javascript
复制
<androidx.constraintlayout.widget.ConstraintLayout 
    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=".Policy.PrivacyPolicy">


    <LinearLayout


        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="#E53935"
            android:textAlignment="center"
            app:popupTheme="@style/Theme.BangabandhuT20Cup.PopupOverlay"
            app:title="@string/privacy_policy_title"
            app:titleTextColor="#FFFFFF">
        </androidx.appcompat.widget.Toolbar>

       


        <WebView
            android:id="@+id/policyWebView"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        </WebView>
        <!--Google Admob Code-->
        <com.google.android.gms.ads.AdView
            android:id="@+id/banner_container00"
            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>
        


    </LinearLayout>


</androidx.constraintlayout.widget.ConstraintLayout >
EN

回答 2

Stack Overflow用户

发布于 2021-08-16 09:56:16

代码语言:javascript
复制
<androidx.constraintlayout.widget.ConstraintLayout 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">


    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="#E53935"
        android:textAlignment="center"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:popupTheme="@style/Theme.BangabandhuT20Cup.PopupOverlay"
        app:title="@string/privacy_policy_title"
        app:titleTextColor="#FFFFFF"></androidx.appcompat.widget.Toolbar>


    <WebView
        android:id="@+id/policyWebView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@id/banner_container00"
        app:layout_constraintTop_toBottomOf="@id/toolbar" />
    <!--Google Admob Code-->
    
    <com.google.android.gms.ads.AdView
        android:id="@+id/banner_container00"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:adSize="BANNER"
        app:adUnitId="@string/ad_id"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"/>
    
</androidx.constraintlayout.widget.ConstraintLayout>
票数 0
EN

Stack Overflow用户

发布于 2021-08-16 10:00:30

您可以使用constraintlayout。

试试这个:

代码语言:javascript
复制
<androidx.constraintlayout.widget.ConstraintLayout 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=".Policy.PrivacyPolicy">



    <androidx.appcompat.widget.Toolbar
        app:layout_constraintTop_toTopOf="parent"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="#E53935"
        android:textAlignment="center"
        app:popupTheme="@style/Theme.BangabandhuT20Cup.PopupOverlay"
        app:title="@string/privacy_policy_title"
        app:titleTextColor="#FFFFFF"></androidx.appcompat.widget.Toolbar>



<WebView
    android:id="@+id/policyWebView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    app:layout_constraintTop_toBottomOf="@id/toolbar"
    app:layout_constraintBottom_toTopOf="@id/banner_container00"/>

<!--Google Admob Code-->
<com.google.android.gms.ads.AdView
    android:id="@+id/banner_container00"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    app:adSize="BANNER"
    app:adUnitId="ca-app-pub-2820216276511886/6822924493"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent">

</com.google.android.gms.ads.AdView> </androidx.constraintlayout.widget.ConstraintLayout>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68800508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档