Search code examples
c#androidxamarin.androidandroid-statusbar

Authenticator GetUI draws behind status bar


I made an app in xamarin.android which makes user log in to google using xamarin.auth and OAuth2. The problem is, when i start the activity for login UI, the webview shows behind the status bar. I have a navigationdrawer in my project, but it has the fitsSystemWindows set to true. I have tried moving the fitssystemwindows around, changing it etc., but nothing really worked.

Thanks in advance :)

-EDIT-

Here is a screenshot: GetUIBehindStatusBar. My layout:

<android.support.v4.widget.DrawerLayout 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:id="@+id/drawerLayout1"
    android:fitsSystemWindows="true">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:minHeight="?attr/actionBarSize"
            android:background="?attr/colorPrimary" />
    </LinearLayout>
    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:headerLayout="@layout/drawerheader"
        app:menu="@menu/leftdrawermenu" />
</android.support.v4.widget.DrawerLayout>

I use this command to display the UI:

StartActivity(authenticator.GetUI(this));

Solution

  • Setting <name="android:windowTranslucentStatus">true</item> will not only set the status bar be translucent but also put the view shows behind the status bar.

    I suggest you remove the android:windowTranslucentStatus or set the value is false and remove the <item name="android:statusBarColor">@android:color/transparent</it‌​em> because it will set the status bar transparent.

    And the customer style code should be like as follows:

    <?xml version="1.0" encoding="utf-8" ?>
    <resources>
    
      <style name="MyCustomTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:windowTranslucentStatus">false</item>
      </style>
    </resources>
    

    If you want to use <item name="android:statusBarColor">@android:color/transparent</it‌​em> please use the minimun sdk 21. This feature is added in android API 21 above.

    The screen shows as below:

    enter image description here