I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.skillberg.weather.ui.activity.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="@+id/weather_rv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true" />
</android.support.design.widget.CoordinatorLayout>
And style:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
I want the first item in RecyclerView to be displayed under the status bar (like toolbar), but it's not being displayed there:
However, RecyclerView itself draws under status bar, but it seems that there is some top padding which height = status bar height:
How to fix it?
Expand your AppTheme
with windowTranslucentStatus
e.g.
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowTranslucentStatus">true</item>
// other stuff
</style>
This will allow the StatusBar
to be transparent. You don't need to use android:fitsSystemWindows
.