SearchView on support.v7.appcompat library issue: default 9-patch background not renders properly

I’m developing an app with ActionBar using support.v7.appcompat library. The action bar works, the SearchView is shown, the hint shows. The only problem is that the background of the SearchView is not scalling properly. Insead of the usual, it appears big and with the 9-patch black lines.


  • Developing from command line, using ant debug to compile.
  • On Linux Mageia 3, ant version: Apache Ant(TM) version 1.8.4 compiled on January 11 2013
  • Linking to library with line:


  • Finish an activity from another activity
  • Preference sub-screen not opening when using support.v7.preference
  • EditText cursor becomes invisible in JellyBean
  • Genymotion - The virtual device got no IP Address
  • Canvas.clipPath(Path) not clipping as expected
  • Android SDK manager won't open
    • Using @style/Theme.AppCompat.Light
    • Tested in device with CM10-1, in device with stock 4.1, and emulator with API 8 (Android 2.2). Same result in all devices.


    enter image description here

    Code: (main activity):

    import android.content.Context;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.MenuInflater;
    public class DiccionariCatala extends ActionBarActivity
        /** Called when the activity is first created. */
        public void onCreate(Bundle savedInstanceState)
        public boolean onCreateOptionsMenu(Menu menu){
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(, menu);
            SearchManager SManager =  (SearchManager) getSystemService(Context.SEARCH_SERVICE);
            MenuItem searchMenuItem = menu.findItem(;
            SearchView searchViewAction = (SearchView) MenuItemCompat.getActionView(searchMenuItem);
            return super.onCreateOptionsMenu(menu);
        public boolean onOptionsItemSelected(MenuItem item){
            switch (item.getItemId()) {
                        return true;
                        return super.onOptionsItemSelected(item);

    menu_actions.xml (menu xml)

    <menu xmlns:android=""
          xmlns:diccionaricatala="" >
        <item android:id="@+id/action_search"
              diccionaricatala:actionViewClass="" />


    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android=""
          <uses-sdk android:minSdkVersion="8"  android:targetSdkVersion="16"/>
          <application android:label="@string/app_name"
           <activity android:name="DiccionariCatala"
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                    <action android:name="android.intent.action.SEARCH" />
                <meta-data android:name=""


    Any help would me much apreciated. I can’t find anything wrong, and there’s also the weird fact that despide this, everything else work. Thanks.

  • How does Android determine if an app has “High Battery Use” under “Recent Location Requests”?
  • GET_TASKS Permission Deprecated
  • Recorded video is 90 degree rotated after uploading to Internet
  • Which is better? Native App or hybrid App?
  • Why does use of multiDexEnabled (true) allow the app to build but constantly crash?
  • Obfuscation: hide hardcoded values in java
  • 3 Solutions collect form web for “SearchView on support.v7.appcompat library issue: default 9-patch background not renders properly”

    Ok, I want to kill myself. I’ve fixed it. Don’t know how. I can’t reproduce the bug again!

    what I think has fixed the bug: I’ve added import;

    Then I’ve removed it to reproduce the bug, but it’s not back.

    I also did uninstall Build-tools 18.0.1 (which is in italics and made me suspicious), so I thought it might be the source of the bug. But I’ve reinstalled it, and can’t reproduce the bug either.

    I don’t know what else could possibly be. Anyway, moving on… (sight)


    It happened again, and this time I’ve been able to narrow it down. Turns out it is a bug of Build Tools v18.*, downgrading to v17 solves the issue.

    This is usually an issue where the resources (R) file has not been correctly generated and some references are misaligned.

    Doing a clean is usually a good fix, as it regenerates this file. This is what you inadvertently did when reinstalling.

    I had the same issue with build tools 19.0.1, but newer version 19.0.3 fixed the problem. Try it, hopefully it will help you too.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.