找不到与给定名称匹配的资源(在'layout_above'值为"@id/adView")。即使在 AdView 拥有该 ID 之后



我正在开发一个安卓应用程序,但在添加 AdView 后,它显示错误错误:(23, 31( 找不到与给定名称匹配的资源(在"layout_above"处,值为"@id/adView"(。

XML代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center"
android:background="@drawable/bg_lock"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp" />
<FrameLayout
android:layout_below="@id/toolbar"
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/adView"
android:layout_marginBottom="5dp"/>
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/addUnit" />
</RelativeLayout>

我仍然收到错误。请帮助我

使用android:layout_above="@+id/adView"它会起作用。

由于您已在广告浏览上方声明了框架布局,因此请添加 @+id 而不是@id

android:layout_above="@+id/adView"

最新更新