我有一个 android 相对布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.my.view.text.MyTextView
style="@style/textOnBg"
android:layout_toLeftOf="@id/SkipIcon2"
android:text="Skip"
android:textStyle="normal" />
<ImageView
android:id="@+id/SkipIcon2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/signup_skip_icon" />
</RelativeLayout>
我怎么会收到这个错误:
错误:错误:找不到与给定名称匹配的资源(位于“layout_toLeftOf”,值为“@id/”)
SkipIcon2').
最佳答案
试试这个..
您错过了android:layout_toLeftOf="@+id/SkipIcon2"
@+id
<com.my.view.text.MyTextView
style="@style/textOnBg"
android:layout_toLeftOf="@+id/SkipIcon2"
android:text="Skip"
android:textStyle="normal" />
嗯,这取决于上下文,当您使用 android:id
的 XML 属性时,您将指定一个新的 id
,并指示解析器(或称其为构建器)在 R.java
中创建一个新条目,因此您必须包含一个 +
符号。
关于java - 未找到与给定名称匹配的资源,即使该资源存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20633502/