Android.Views.View.FitSystemWindows Method
Called by the view hierarchy when the content insets for a window have changed, to allow it to adjust its content to fit within those windows.

Syntax

[Android.Runtime.Register("fitSystemWindows", "(Landroid/graphics/Rect;)Z", "GetFitSystemWindows_Landroid_graphics_Rect_Handler")]
[System.Obsolete("deprecated")]
protected virtual bool FitSystemWindows (Android.Graphics.Rect insets)

See Also

View.FitsSystemWindows
View.SetFitsSystemWindows(bool)
View.SystemUiVisibility

Parameters

insets
Current content insets of the window. Prior to NoType:android/os/Build$VERSION_CODES;Href=../../../reference/android/os/Build.VERSION_CODES.html#JELLY_BEAN you must not modify the insets or else you and Android will be unhappy.

Returns

Documentation for this section has not yet been entered.

Remarks

Called by the view hierarchy when the content insets for a window have changed, to allow it to adjust its content to fit within those windows. The content insets tell you the space that the status bar, input method, and other system windows infringe on the application's window.

You do not normally need to deal with this function, since the default window decoration given to applications takes care of applying it to the content of the window. If you use View.SystemUiFlagLayoutFullscreen or View.SystemUiFlagLayoutHideNavigation this will not be the case, and your content can be placed under those system elements. You can then use this method within your view hierarchy if you have parts of your UI which you would like to ensure are not being covered.

The default implementation of this method simply applies the content insets to the view's padding, consuming that content (modifying the insets to be 0), and returning true. This behavior is off by default, but can be enabled through View.SetFitsSystemWindows(bool).

This function's traversal down the hierarchy is depth-first. The same content insets object is propagated down the hierarchy, so any changes made to it will be seen by all following views (including potentially ones above in the hierarchy since this is a depth-first traversal). The first view that returns true will abort the entire traversal.

The default implementation works well for a situation where it is used with a container that covers the entire window, allowing it to apply the appropriate insets to its content on all edges. If you need a more complicated layout (such as two different views fitting system windows, one on the top of the window, and one on the bottom), you can override the method and handle the insets however you would like. Note that the insets provided by the framework are always relative to the far edges of the window, not accounting for the location of the called view within that window. (In fact when this method is called you do not yet know where the layout will place the view, as it is done before layout happens.)

Note: unlike many View methods, there is no dispatch phase to this call. If you are overriding it in a ViewGroup and want to allow the call to continue to your children, you must be sure to call the super implementation.

Here is a sample layout that makes use of fitting system windows to have controls for a video view placed inside of the window decorations that it hides and shows. This can be used with code like the second sample (video player) shown in View.SystemUiVisibility.

xml Example

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="match_parent"
    >
    <view class="com.example.android.apis.view.VideoPlayerActivity$Content"
        android:id="@+id/content"
        android:src="@drawable/frantic"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="center"
        />
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:animateLayoutChanges="true"
        >
        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="top|center_horizontal"
            android:textColor="#ffffffff"
            android:background="#a0000000"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:gravity="left"
            android:padding="16dp"
            android:text="A title goes here"
            />
        <Button
            android:id="@+id/play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:textSize="28dp"
            />
        <SeekBar
            android:id="@+id/seekbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|center_horizontal"
            android:layout_marginBottom="16dp"
            />
    </FrameLayout>
</FrameLayout>

[Android Documentation]

Requirements

Namespace: Android.Views
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1