2016-01-04 31 views
4

此:没有资源发现在给定的名字相匹配(在 'layout_alignTop',值为 '@ ID/imageView3')

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
tools:context=".MainActivity" 
android:weightSum="1"> 

<ImageView 
    android:id="@+id/imageView2" 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    android:layout_alignTop="@id/imageView3" 
    android:layout_toLeftOf="@id/imageView3" 
    android:layout_marginRight="30dp"/> 



<ImageView 
    android:id="@+id/imageView3" 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    android:layout_gravity="center_horizontal" 
    android:layout_marginTop="30dp" 
    android:layout_centerHorizontal="true"/> 

<ImageView 
    android:id="@+id/imageView4" 
    android:layout_width="100dp" 
    android:layout_height="100dp" 
    android:layout_alignTop="@id/imageView3" 
    android:layout_toRightOf="@id/imageView3" 
    android:layout_marginLeft="30dp"/> 

</RelativeLayout> 

是我的AndroidManifest.xml中,我得到的错误:

错误:(77,35)找不到与给定名称相匹配的资源(位于'layout_alignTop',值为'@ id/imageView3')。

错误:(78,35)找不到与给定名称相匹配的资源(位于'layout_toLeftOf',值为'@ id/imageView3')。

+0

您正在使用哪个IDE? Eclipse还是Android Studio? –

+1

谢谢@IntelliJ Amiya解决了我的问题,我忘了首先添加“+符号”。 – JimmyHo

+1

它在Android Studio上工作 – JimmyHo

回答

11

您可以使用。首先添加+标志。

android:layout_alignTop="@+id/imageView3" 

之后,清洁重建重启IDE

+1

谢谢,这正是我所期待的。 – JimmyHo

+1

确实有效,但我不明白为什么我们需要这里的'+'。我认为@ + ID意味着我们想创建一个新的ID,而不是指现有的ID。这对我来说看起来像是一种解决方法来隐藏某些东西。事实上,虽然我使用的是相同的布局,但有些情况下我不需要这种破解。如果有人知道更多我会感兴趣... – DrMad

0

我得到了同样的结果,但后来我的问题是我不小心将视图移到了它所引用视图的上方。

原始代码

<ImageView 
    android:id="@+id/image_view" 
    android:width="wrap_content" 
    android:height="wrap_content"> 
<ScrollView 
    android:id="@+id/scroll_view" 
    android:width="wrap_content" 
    android:height="wrap_content" 
    android:layout_below="@id/image_view"> 
    <LinearLayout 
     ... > 
     ... 
    </LinearLayout> 
</ScrollView> 

然后我把它调整到像

<ScrollView 
    android:id="@+id/scroll_view" 
    android:width="wrap_content" 
    android:height="wrap_content" 
    android:layout_below="@id/image_view"> 
    <LinearLayout 
     ... > 
     <ImageView 
      android:id="@+id/image_view" 
      android:width="wrap_content" 
      android:height="wrap_content"> 
     <ImageView 
      android:id="@+id/image_view2" 
      android:width="wrap_content" 
      android:height="wrap_content" 
      android:layout_below="@id/image_view"> 
     ... 
    </LinearLayout> 
</ScrollView> 

我很奇怪,因为IDE指示着第二内部行

android:layout_below="@id/image_view" 

错误ImageView,所以我花了一段时间才发现错误确实在

android:layout_below="@id/image_view" 

在ScrollView,我忘了删除。

相关问题