Search code examples
androidlistviewandroid-listviewnavigationbar

Bottom soft NavigationBar overlaps my ListView


I ran my app on a Nexus 5 (Android 5) but I encountered the problem that the soft NavigationBar at the bottom overlaps the last item of my ListView. I've tried to add fitsSystemWindows to my style and the ListView but that didn't work.

The XML of my layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:background="@color/sf4l"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ListView android:id="@id/android:list"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:background="@color/sf4l" />
</LinearLayout>

Solution

  • Add this to your themes.xml in a values-v21 dir:

    <item name="android:windowDrawsSystemBarBackgrounds">false</item>
    

    Example (I'm using AppCompat for actionbars):

    <style name="Theme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="homeAsUpIndicator">@drawable/new_indicator</item>
        <item name="android:homeAsUpIndicator">@drawable/new_indicator</item>
        <item name="actionModeBackground">@android:color/black</item>
        <item name="android:windowDrawsSystemBarBackgrounds">false</item>
    </style>