Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Translucent status bar not working with Google Maps API

I have a problem where the status bar will not turn translucent. The translucent status bar and navigation bar code works fine by itself, however, when I implement the Google Maps Fragment into the activity view, the translucent bar turns gray. I have tested this with a fully transparent status bar but which again works at first, then has a white background once maps is added. It seems as if Google Maps has some sort of overlay. Any help is appreciated to get status bar to be translucent with Google Maps API.

As

XML File

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">


    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="com.example.mapwithmarker.MapsMarkerActivity"
        tools:layout="@layout/activity_main" />

</android.support.v4.widget.DrawerLayout>

Translucent status bar

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
like image 788
Lord Goderick Avatar asked Jan 17 '17 12:01

Lord Goderick


People also ask

How do I change the color of my status bar?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method.

What is Android Statusbar?

Status bar (or notification bar) is an interface element at the top of the screen on Android devices that displays the notification icons, minimized notifications, battery information, device time, and other system status details.


1 Answers

I have found the solution. Set android:fitsSystemWindows in DrawerLayout to "false", if anyone is adding a map to drawer layout.

like image 177
Lord Goderick Avatar answered Sep 23 '22 00:09

Lord Goderick