I have an Activity
which is displayed fullscreen. This works perfectly with many layouts I have tried, except for when the CoordinatorLayout
is the root ViewGroup
. The CoordinatorLayout
itself has both width and height set to match_parent
and it takes the whole screen as it should. But the child views that should have the same size as the CoordinatorLayout
are laid as if the navigation bar was still visible.
Is there a way to make the child views resize with the CoordinatorLayout
? Obviously fitSystemWindows
does not change a thing as this is probably caused by the CoordinatorLayout
implementation, other ViewGroups
work well. I have tried to create custom Behavior
class but I was not successful with that.
I use this code to make my Activity
fullscreen:
@Override
protected void onResume() {
super.onResume();
int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
getWindow().getDecorView().setSystemUiVisibility(uiOptions);
}
This is a simple layout used to generate the image:
<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:fitsSystemWindows="true"
android:background="#F00">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
android:src="@drawable/background_sky_light" />
</android.support.design.widget.CoordinatorLayout>
change android:fitsSystemWindows to false if you are using coodinatorlayout
android:fitsSystemWindows="false
"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With