Search code examples
androidandroid-toolbar

android space under appbar


I'm trying to place two Fragments next to each other, but I can't get rid of a space between the ActionBar and my application contents :

Toolbar spacing screenshot

Here is my XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:layout_height="match_parent"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:elevation="0dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.tce.manager.MainActivity"
    tools:showIn="@layout/app_bar_main">

    <fragment
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:elevation="2dp"
        android:name="com.tce.manager.DeviceListFragment"
        android:layout_weight="3"
        android:id="@+id/fragment_device_list" />

    <FrameLayout
        android:background="@android:color/darker_gray"
        android:elevation="0dp"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="2" />

</LinearLayout>

I already tried to change margins and padding for the Toolbar and AppBarLayout


Solution

  • Remove android:fitsSystemWindows="true"

    If it's set to true, then it adjusts the padding of this view to leave space for the system windows.