Rendering problems Failed to resolve @ id / search_edit_frame resource

Rendering problems Failed to resolve @ id / search_edit_frame resource

This is a display error that I get in my XML file. I think this has something to do with my support.v7.SearchView below, this is my xml:

  <RelativeLayout android:id="@+id/layout_ricerca" android:layout_width="match_parent" android:layout_height="50dp" android:background="@drawable/search_border_backgroud" android:layout_marginStart="10dp" android:layout_marginEnd="10dp" android:layout_marginTop="20dp"> <android.support.v7.widget.SearchView android:id="@+id/testo_ricerca" android:layout_width="wrap_content" android:layout_height="wrap_content" android:queryHint="@string/search_hint" android:textSize="25sp" android:layout_marginStart="5dp" android:iconifiedByDefault="false"/> <ImageButton android:id="@+id/tasto_ricerca" android:background="@color/trans" android:layout_marginTop="2dp" android:layout_width="45dp" android:layout_height="match_parent" android:layout_marginEnd="3dp" android:scaleType="centerInside" android:layout_alignParentEnd="true" android:src="@drawable/tasto_ricerca"/> </RelativeLayout> 

When I change <android.support.v7.widget.SearchView to <SearchView , the error disappears, but this is not a good solution for me, because I would have to change all my java code to work with SearchView instead of android.support.v7.widget.SearchView .

Does anyone know how to fix this problem? Why is this happening? I don't think something is wrong with my xml.

Edit:

Error screenshot added

screenshot

+7
android android-layout xml searchview rendering
source share
5 answers

When you have a lot of cache data stored in Android Studio , this time this type of error is suitable.

There are many ways to solve this problem.

  • The fastest way to do this is: File Invalidate caches / Restart... Just Restart .

  • Right click on project and Synchronize ...Project

  • click Build menu select Clean Project and then Rebuild it .
+5
source share

To resolve this issue, provide

 android:id="@+id/search_edit_frame" 

parent view attribute e.g.

 android.support.design.widget.AppBarLayout 

or any ViewGroup that is the parent of your SearchView.

For example:

 <android.support.design.widget.AppBarLayout android:id="@+id/search_edit_frame" android:layout_width="match_parent" android:layout_height="@dimen/my_app_bar_height"> <android.support.v7.widget.SearchView android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.AppBarLayout /> 
+14
source share

use this code

 <SearchView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/searchView" android:iconifiedByDefault="true" android:queryHint="Search" android:layout_centerHorizontal="true" /> 
+1
source share
  android:id="@+id/search_edit_frame" 

add above line to parent layout that helped

+1
source share

Here is a simple solution.

No cache invalidation or restart needed. Just add the line below to the strings.xml file and the problem will be solved.

  <item name="search_edit_frame" type="id"/> 

Bingo!

0
source share

All Articles