我正在构建一个简单的待办事项列表应用程序。我试图通过相互定位来组织我的布局。我通过调用像android:layout_toStartOf="@id/to_do_btn"
这样的XML属性来做到这一点,但是我得到一个No Resource Found That Matches The Given Name
错误。我基本上尝试了Stackoverflow上的每个解决方案,但没有任何帮助这是我的XML:即使名称匹配,“找不到与给定名称匹配的资源”错误
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="myapp.onur.todo.MainActivity">
<ListView
android:id="@+id/to_do_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_above="@id/to_do_btn"
android:layout_margin="5dp"
>
</ListView>
<EditText
android:id="@+id/to_do_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter Something To Do"
android:layout_toStartOf="@id/to_do_btn"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignTop="@id/to_do_btn"
android:layout_below="@id/to_do_list"
android:layout_margin="5dp"
/>
<Button
android:id="@+id/to_do_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="add item"
android:layout_margin="5dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
/>
</RelativeLayout>
这是错误的例子:Error:(15, 31) No resource found that matches the given name (at 'layout_above' with value '@id/to_do_btn').
我不知道发生了什么事情。如果有帮助,这里是我的依赖关系的gradle:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
}
非常感谢。有效!!! –
谢谢,伙计。眼睛打开:) –