Search code examples
androidgoogle-chrome-arc

ARC app resize window event


Now that android apps can be run on the Chrome OS and using {"resize":"reconfigure"} they have become re-sizable, there is now a need for more responsive layouts. In order to make my layout more responsive I need an event listener that knows when the app window changes size.

Is there anyone out there doing this and how?

FYI: I want to do something similar to polymers Scaffold concept(https://www.polymer-project.org/0.5/components/core-elements/demo.html#core-scaffold)


Solution

  • ARC does not send a simple application level event on window resize. Android does define a resize event which is used when the virtual keyboard pops up, but this isn't useful to ARC since it is more about restricting your app to a smaller portion of the display (which is still the same size)

    Instead it sends more of a system level event, causing the Android code to think that the display size has changed. This is substantially the same as what happens when you rotate an Android phone causing an orientation change event to propagate. The Android framework then passes this on to your app as the standard Activity.onConfigurationChanged() call.

    You should be able to then use the values contained in the passed Configuration newConfig argument (such as screenWidthDp and screenHeightDp) to decide how to display your UI.