[英]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.