Blasco73
Blasco73

Reputation: 2990

Problems with relative layout: No resource found that matches the given name

I'm going crazy with this problem... I would like to do something like this: enter image description here

This is my SIMPLY code into the xml layout file:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
    p1:minWidth="25px"
    p1:minHeight="25px"
    p1:layout_width="match_parent"
    p1:layout_height="match_parent"
    p1:id="@+id/relativeLayout1">
    <WebView
        p1:layout_width="match_parent"
        p1:layout_height="wrap_content"
        p1:id="@+id/webView1"
        p1:layout_alignParentTop="true"
        p1:layout_above="@id/textView1" />
    <TextView
        p1:text="Medium Text"
        p1:textAppearance="?android:attr/textAppearanceMedium"
        p1:layout_width="match_parent"
        p1:layout_height="wrap_content"
        p1:id="@+id/textView1"
        p1:layout_alignParentBottom="true" />
</RelativeLayout>

but the error that I receive is this:

Error: No resource found that matches the given name (at 'layout_above' with value '@id/textView1').

That is so strange for me.... because I have specified textView1!!!!

Some idea?!?

Upvotes: 1

Views: 950

Answers (1)

matthewrdev
matthewrdev

Reputation: 12170

The TextView with the id textView1 is parsed after the WebView that is referencing it. Using the @id/* syntax specifies that the parser is resolving an existing id. In this case it will fail as your TextView hasn't been parsed yet.

Use layout_above=@+id/textView1 instead to predeclare the id for your TextView.

Upvotes: 3

Related Questions