My SearchView is showing up like this:
As you can see there is a margin both on the search_edit_frame
of the SearchView, and outside the SearchView itself.
Where is this coming from? Inspecting the layout reveals a margin of 24 pixels to the left of search_edit_frame
but no margin elsewhere.
How can I remove this extra space?
menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/appbar_menu_search"
android:icon="@drawable/ic_search"
android:title="@string/search_search"
app:showAsAction="always"
app:actionViewClass="android.support.v7.widget.SearchView" />
</menu>
Layout:
<RelativeLayout
android:id="@+id/root_layout"
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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/profile_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/topbar_gradient"
android:theme="@style/AppTheme.Dark"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/topbar_gradient"
android:fitsSystemWindows="true"
android:minHeight="?android:attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
(...)
</RelativeLayout>
I managed to reduce the spacing by applying @Jimmy's answer:
However theres still a big gap between the "back" imagebutton and the SearchView.