简体   繁体   English

Android Studio:错误:找不到与给定名称匹配的资源(在'layout_above'处,值为'@ id / adView')

[英]Android Studio: Error: No resource found that matches the given name (at 'layout_above' with value '@id/adView')

I will put a adview (admob) in the bottom of a webview 我将在网页视图的底部放置一个adview(admob)

When I gradle sync, I get this error. 当我进行gradle同步时,会出现此错误。 Could you please help me to solve this issue? 您能帮我解决这个问题吗?

C:\\Users\\danie\\AndroidStudioProjects\\PokemonDamageCalculator\\app\\src\\main\\res\\layout\\activity_main.xml Error:(20, 31) No resource found that matches the given name (at 'layout_above' with value '@id/adView'). C:\\Users\\danie\\AndroidStudioProjects\\PokemonDamageCalculator\\app\\build\\intermediates\\res\\merged\\debug\\layout\\activity_main.xml Error:(20, 31) No resource found that matches the given name (at 'layout_above' with value '@id/adView'). Error:Execution failed for task ':app:processDebugResources'. com.android.ide.common.process.ProcessException: Failed to execute aapt

This is my MainActivity.xml 这是我的MainActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
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"
android:fitsSystemWindows="true"
android:orientation="vertical"
tools:context="danilkp1234.com.pokemondamagecalculator.MainActivity">

<include
    layout="@layout/content_main"
    android:layout_width="match_parent"
    android:layout_height="50dp" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/adView"
    android:layout_weight="1"
    android:orientation="vertical">

    <WebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </WebView>
</LinearLayout>

Replace 更换

android:layout_above="@id/adView"

with

android:layout_above="@+id/adView"

Just need to add '+' after '@' 只需在“ @”之后添加“ +”

Where is the view with the id adView ? ID为adView的视图在哪里?

Also android:layout_above is used for views inside a RelativeLayout , not LinearLayout . android:layout_above也用于RelativeLayout内的视图,而不是LinearLayout内的视图。 In a RelativeLayout views can be placed below, on top or next to each other with android:layout_... attributes. RelativeLayout可以使用android:layout_...属性将视图置于下面,之上或彼此相邻。 LinearLayout automatically puts views below or next to one another depending on the android:orientation parameter. LinearLayout根据android:orientation参数自动将视图置于下方或彼此相邻。

If you want to continue using LinearLayout you should remove 如果要继续使用LinearLayout ,则应删除

android:layout_above="@id/adView"

I hope this helps. 我希望这有帮助。

You have an error in android:layout_above="@id/adView" At first try to change @id/adView to @+id/adView. 您在android:layout_above="@id/adView"出错。首先尝试将@id/adView to @+id/adView.更改@id/adView to @+id/adView.

Also, android:layout_above="" is used in RelativeLayout , hence your LinearLayout won't affect any change. 另外,在RelativeLayout使用了android:layout_above="" ,因此您的LinearLayout不会影响任何更改。 Change the parent LinearLayout to RelativeLayout and then add further View (having id adView ) to affect a change. 将父LinearLayout更改为RelativeLayout,然后添加更多View(具有id adView )以影响更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到与给定名称匹配的资源(位于“ layout_above”,值为“ @ id / adView”)。 即使在AdView具有该ID之后 - No resource found that matches the given name (at 'layout_above' with value '@id/adView'). even after AdView have that id 自定义布局文件破坏了我的Android应用程序(找不到与给定名称匹配的资源(在“ layout_above”处具有值)) - Custom layout file destroys my Android application (No resource found that matches the given name (at 'layout_above' with value)) [Android] [XML]错误:(19,31)找不到与给定名称匹配的资源。(layout_above) - [Android][XML]Error:(19, 31) No resource found that matches the given name.(layout_above) RelativeLayout 的 layout_above 给出“未找到资源”错误 - RelativeLayout's layout_above gives “No resource found” error Android错误:找不到与Android Studio中的给定名称匹配的资源 - Android Error: No resource found that matches the given name in Android Studio Android:Layout_above adview在列表视图上不起作用 - Android: Layout_above adview not working on List view 在Android Studio中构建项目时出错“错误:找不到与给定名称匹配的资源(在____处使用值&#39;@ drawable / <name> “) - Error Building Project in Android Studio "Error: No resource found that matches the given name (at ____ with value '@drawable/<name>') 字体android studio 3错误:找不到与给定名称匹配的资源 - Error with fonts android studio 3: No resource found that matches the given name Android Studio - 错误:找不到与给定名称匹配的资源:attr&#39;metaButtonBarButtonStyle&#39; - Android Studio - Error: No resource found that matches the given name: attr 'metaButtonBarButtonStyle' Android Studio-找不到与给定名称匹配的资源 - Android Studio - No resource found that matches the given name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM