Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get existing window insets after dispatch?

Tags:

android

Is there a way to fetch an activity's WindowInsets at will, long past the activity's creation, without holding on to it or otherwise caching it?

eg.

WindowInsets insets = getWindow().getWindowInsets();
myUseCaseView.setPaddingTop(insets.getSystemWindowInsetTop);
like image 724
Tom Avatar asked Apr 18 '17 04:04

Tom


People also ask

What is window insets in Android?

android.view.WindowInsets. Describes a set of insets for window content. WindowInsets are immutable and may be expanded to include more inset types in the future. To adjust insets, use one of the supplied clone methods to obtain a new WindowInsets instance with the adjusted properties.

What is a window inset?

WindowInsets are insets (or sizes) of system views (e.g. status bar, navigation bar), that are applied to the window of your application. The best way to understand something — is to see it in example.


1 Answers

Yes: getWindow().getDecorView().getRootWindowInsets()

like image 57
rds Avatar answered Nov 15 '22 16:11

rds