微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 SwipeRefreshLayout 在屏幕底部显示横幅广告视图?

如何解决如何使用 SwipeRefreshLayout 在屏幕底部显示横幅广告视图?

总结一下我的问题: 我有一个在 SwiperRefreshLayout 中使用的 RecylerView。 除了这两个,我想在屏幕底部添加一个横幅广告。 当我在 SwipeRefreshLayout 上方添加标签 com.google.android.gms.ads.AdView 时,它看起来像这样:

Tag at top

但是当我在 SwipeRefreshLayout 下面添加 adview 的标签时,它消失了。屏幕上只显示 Recylerview。

没有广告:

Tag at bottom

如何将广告固定在屏幕底部

我的代码是这样的:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="wrap_content"
    android:background="@drawable/blur"
    android:orientation="vertical"
    tools:context=".MainActivity">

    
    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/swipeRefreshLayout"
        android:layout_width="match_parent"
        android:layout_above="@+id/adView"
        android:layout_height="wrap_content">


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycleView"
        android:layout_above="@+id/adView"
        android:layout_margin="2dp"
        android:scrollbars="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>


    <com.google.android.gms.ads.AdView
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
        android:layout_above="@+id/swipeRefreshLayout" />
    
</LinearLayout>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。