How to get window width in multiple window mode Android 7?

Viewed 1074

Since Android 7.0 we have multiple window mode. See example in this picture:

enter image description here

User can change the width of window.

How can I get the real width of window?

2 Answers

Works for me:

Activity yourActivity = ...
DisplayMetrics displayMetrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int windowWidth = displayMetrics.widthPixels;
Related