Android 我的广告没有播出

Android 我的广告没有播出,android,ads,Android,Ads,大家好。。。 我有应用程序的源代码 当我更改admob的代码时,我的广告不会显示。 有什么问题吗? 在我看来,XML就是问题所在。您在ConstraintLayout中嵌套了RelativeLayout。这绝不是一个好主意。ConstraintLayout的整个要点是能够生成平面布局树,而不是嵌套布局。其次,我能看到的最大问题是框架布局的高度与父项匹配。这将与您的广告重叠,因此您的广告将永远不可见 因此,我的建议是,首先删除相对布局,然后进行约束,使框架底部不与广告重叠。我还将更改高度以包裹内容

大家好。。。 我有应用程序的源代码 当我更改admob的代码时,我的广告不会显示。 有什么问题吗?

在我看来,XML就是问题所在。您在ConstraintLayout中嵌套了RelativeLayout。这绝不是一个好主意。ConstraintLayout的整个要点是能够生成平面布局树,而不是嵌套布局。其次,我能看到的最大问题是框架布局的高度与父项匹配。这将与您的广告重叠,因此您的广告将永远不可见

因此,我的建议是,首先删除相对布局,然后进行约束,使框架底部不与广告重叠。我还将更改高度以包裹内容,使其填充视图,但不重叠

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay"
            android:id="@+id/view">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways|snap"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.AppBarLayout>

        <FrameLayout
            android:id="@+id/fragment1"
            android:layout_width="match_parent"                
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            app:layout_constraintBottom_toTopOf="@id/adView"/>

        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_gravity="center"
            ads:adSize="BANNER"
            ads:adUnitId="@string/admob_publisher_id" />
</android.support.design.widget.CoordinatorLayout>

我没有花时间去填补所有的限制你必须为自己做一些!,但是这个限制会让你开始。了解约束的作用。它可以使布局更加灵活。

为adview展示一些源代码和您的XML,截图一点帮助都没有这个问题不清楚!你的错误到底是什么?正如@TimothyWinters所提到的,向我们提供您的工作,以便我们能够了解问题所在。如果适用,也提供Logcat。这是源代码更改admob的ID您将知道我的意思谢谢Timothy Winters您非常欢迎!我希望这会有所帮助,并希望您在这个过程中学到一些东西: