Solve margin Searchview expandable and Toolbar Android

Solve margin Searchview expandable and Toolbar Android

This margin / padding issue often occured when searchview widget have left space that push another icons in toolbars.
To solve this issues, we remove padding left in toolbar and adjust the TitleMarginStart margin accordingly.
This is example of the codes:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!-- Important to set margin title because 0dp by insetleft -->
<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/actionBarSize"
    android:minHeight="?android:attr/actionBarSize"
    android:background="@color/md_black_1000"
    app:layout_scrollFlags="scroll|enterAlways"
    android:contentInsetLeft="0dp"
    android:contentInsetRight="@dimen/_10sdp"
    android:contentInsetStart="0dp"
    app:contentInsetLeft="0dp"
    app:contentInsetRight="@dimen/_10sdp"
    app:contentInsetStart="0dp"
    app:contentInsetStartWithNavigation="0dp"
    app:titleMarginStart="@dimen/_12sdp"
    android:orientation="horizontal"
    app:theme="@style/MyThemeOverlay.ActionBar"
    app:titleTextAppearance="@style/Toolbar.TitleText"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

Leave a Reply

Your email address will not be published. Required fields are marked *