1 is what I want to archive, but what it looks like atm is 2
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:title="Edit Profile"
app:titleTextColor="@android:color/white" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
.....
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
I tried almost every solution on Stack Overflow,
e.g.
fitsSystemWindows="true"
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
and many more..
I don't think it should be this difficult. Any suggestions or example projects are appreciated.
I just figured it out, but I don't know how.
I tried all the possible android:fitsSystemWindows="true"
combinations before but none of the combination worked, but after I changed bunch of layouts, it's just suddenly fixed.
I tracked down every single lines of code changes,
and it turned out I should remove android:fitsSystemWindows="true"
option from the AppBarLayout
.
It's really weird because I tried exactly the same thing about 3 times before, but it didn't have any effect on the layout.
I think it's probably a caching issue or some bug on annoying Android Studio again..
If anyone suffer from similar issues with me, I would recommend
1. clean project
2. remove the layout entirely and put it back
to see the actual changes
I wasted about 5 hours on this problem and the lesson is just "don't trust Android Studio"