Search code examples
androidandroid-layoutsearchview

searchView in toolbar has a paddingBottom when fitsSystemWindows


In my style.xml:

    <item name="android:windowTranslucentStatus">true</item>

In my toolbar.xml:

    <android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/AppTheme.PopupOverlay">

And when I input something it looks like: enter image description here

enter image description here

So my question is: Why it has a bottom padding? And, how to use fitsSystemWindows but make the bottom padding zero?

My temporary solution is: use android:paddingTop="XXdp" instead of android:fitsSystemWindows="true"

but it not elegant.


Solution

  • I just search on Baidu and found a perfect solution.

    http://www.th7.cn/Program/Android/201603/780326.shtml

    just add this to manifast

    android:windowSoftInputMode="adjustPan"