title: Search view on Action bar not expanding completely in Android
body: <p>I added search view to action bar and opened it always in expanded mode. It always taking margin from right I don't know why. I tried many solutions but still no success. Please help to me solve this issue.</p>
  
  <p>Here is the menu code</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          tools:context="com.don.offers.activities.FunHandlerSearchActivity"
          &gt;
          &lt;item
              android:id="@+id/action_search"
              android:icon="@drawable/ic_magnify_grey600_24dp"
              app:showAsAction="collapseActionView|never"
              android:title="@string/search_title"
              app:actionViewClass="android.support.v7.widget.SearchView"
              android:imeOptions="actionSearch"
              /&gt;
  
      &lt;/menu&gt;
  </code></pre>
  
  <p>Searchable code</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  
      &lt;searchable
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:label="@string/app_name"
          android:hint="@string/search_for_friend"
          android:imeOptions="actionSearch"&gt;
      &lt;/searchable&gt;
  </code></pre>
  
  <p>Activity code </p>
  
  <pre><code> @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.fun_handler_search_menu, menu);
      // Associate searchable configuration with the SearchView
      SearchManager searchManager =
              (SearchManager) getSystemService(Context.SEARCH_SERVICE);
      SearchView searchView =
              (SearchView) menu.findItem(R.id.action_search).getActionView();
  
      MenuItem searchMenuItem = menu.findItem(R.id.action_search);
      searchMenuItem.expandActionView();
  
      searchView.setSearchableInfo(
              searchManager.getSearchableInfo(getComponentName()));
  
      searchView.setSubmitButtonEnabled(true);
      searchView.setOnQueryTextListener(this);
  
      try {
          ((EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setHintTextColor(getResources().getColor(R.color.action_bar_grey_color));
          ((EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setTextColor(getResources().getColor(R.color.action_bar_text_grey_color));
  
      } catch (Resources.NotFoundException e) {
          e.printStackTrace();
      }
  
      try {
          ImageView searchClose = (ImageView) searchView.findViewById(android.support.v7.appcompat.R.id.search_close_btn);
          searchClose.setImageResource(R.drawable.ic_clear_24dp);
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() {
          @Override
          public boolean onMenuItemActionExpand(MenuItem item) {
              return true;
          }
  
          @Override
          public boolean onMenuItemActionCollapse(MenuItem item) {
              finish();
              overridePendingTransition(R.anim.slide_right_in, R.anim.slide_right_out);
              return true;
          }
      });
      return true;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/GuJvs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GuJvs.png" alt="enter image description here"></a></p>