I use a MainActivity with a container for my fragments. The MainActivitie's XML contains a toolbar with the following code:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/c_green"
android:id="@+id/toolbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:title="@string/app_name"
android:contentInsetLeft="10dp"
android:contentInsetStart="10dp"
app:contentInsetLeft="10dp"
android:layout_margin="0dp"
android:padding="0dp">
<ImageView
android:id="@+id/logo"
android:layout_width="100dp"
android:layout_height="35dp"
android:layout_gravity="left" />
</android.support.v7.widget.Toolbar>
The problem is the following: On all my fragments I have this unwanted extra space underneath the ActionBar as can be seen in the picture.
When on a recyclerView you can see the CardViews slide underneath the whitespace. I guess there is something wrong with the ActionBar. I tried to add padding 0dp and margin 0dp, but none of that changed anything.
Thanks in advance!
I have found that instead of using
android:layout_marginTop="?attr/actionBarSize"
in my fragments, using
android:layout_marginTop="@dimen/myActionBar_height"
with
<dimen name="myActionBar_height">48dp</dimen>
fixed the extra space. However I don't find this a good solution.
The problem seems to be an extra 10dp of margin top.