Android xml error: “No resource found that matches the given name” with RelativeLayout (@id/LinearLayout_acc, @id/ProgressBar_statusScreen)

前端 未结 4 1697
自闭症患者
自闭症患者 2020-12-05 01:49

Okay, so this is starting to really annoy me. This error pops up in a very special, not very logical way.

Let me start out by saying that I have already looked at th

相关标签:
4条回答
  • 2020-12-05 02:00

    Change every id @id to @+id, no matter when it's defining or referencing an id. With this, you won't get

    Android xml error: “No resource found that matches the given name” with RelativeLayout (@id/LinearLayout_acc, @id/ProgressBar_statusScreen).

    0 讨论(0)
  • 2020-12-05 02:20
     <LinearLayout
            android:id="@+id/LinearLayout_dist"
            android:layout_above="@+id/LinearLayout_acc" <--- here might be a problem you forgot + sign
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="10dp" >
    
    0 讨论(0)
  • 2020-12-05 02:22

    Please check the below code

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/ic_launcher" >
    
    <TableLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    
    <LinearLayout
        android:id="@+id/LinearLayout_dist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/LinearLayout_acc"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp" >
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="FIRST" />
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="SECOND" />
       </LinearLayout>
    
       <LinearLayout
        android:id="@+id/LinearLayout_acc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/ProgressBar_statusScreen"
        android:layout_centerHorizontal="true" >
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="THIRD" />
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="FOURTH" />
       </LinearLayout>
    
       <ProgressBar
        android:id="@+id/ProgressBar_statusScreen"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="16dp" />
    
     </RelativeLayout>
    

    Also check the following link. It says that android:layout_below="@id/myTextView" won't recognise an element with id "myTextView" if it is written after the element you're using it in.

    0 讨论(0)
  • 2020-12-05 02:23

    change

    @id/LinearLayout_acc
    

    to

    @+id/LinearLayout_acc
    
    0 讨论(0)
提交回复
热议问题