Seems to be a unique case compared to other similar situations, but I have a map fragment within a FrameLayout that has a "translucent" toolbar and status bar (darker, transparent color).
I put in the top container
android:fitsSystemWindows="false"
as suggested in other posts, and that works in my other activities, but with my map fragment it doesn't.
I want the map to take up the whole screen, and slide under the status bar, and I want the toolbar to sit just below the status bar. I add some margin to the top of the toolbar in hopes to push it down below the status bar, but it maintains a gap between it and the status bar, plus it's unreliable to set a straight top margin without knowing the exact height of the status bar on a device.
In the first image, I don't have a margin_top set. In the second, you can see the gap, and if you look closely, you can see where the status bar background is in relation to the status items, it's touching them on the bottom as if it's being pushed up.
activity_layout
<FrameLayout 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="false">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#59000000"
tools:ignore="UnusedAttribute"/>
activity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Make to run your application only in portrait mode
getWindow().setStatusBarColor(getResources().getColor(R.color.status_bar_dark));
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(true);
}
...}
styles.xml
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>