Example usage for android.view View requestApplyInsets

List of usage examples for android.view View requestApplyInsets

Introduction

In this page you can find the example usage for android.view View requestApplyInsets.

Prototype

public void requestApplyInsets() 

Source Link

Document

Ask that a new dispatch of #onApplyWindowInsets(WindowInsets) be performed.

Usage

From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java

/**
 * Applies top window insets for a view.
 *
 * @param view The view to apply insets for.
 *///from   w ww . j av  a  2 s  .  com
public static void applyTopWindowInsetsForView(@NonNull final View view) {
    view.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            v.setPadding(v.getPaddingLeft(), insets.getSystemWindowInsetTop() + v.getPaddingTop(),
                    v.getPaddingRight(), v.getPaddingBottom());
            return insets;
        }
    });
    view.requestApplyInsets();
}