0

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)

BillHaggerty
  • 6,157
  • 10
  • 35
  • 68
  • 2
    Hopefully, this triggers normal configuration change logic, just as if the user rotated the screen. – CommonsWare Apr 13 '15 at 19:03
  • 2
    Yes, all it does is trigger a configuration change. There is no resize event in Android, since most devices have small screens, and so apps just display full-screen. The closest even to anything like that is when the virtual keyboard pops up. But when the ARC window is resized, the entire display surface available to your app is resized unlike the keyboard popup. – Lloyd Pique Apr 13 '15 at 19:50
  • @LloydPique You want to put that in an answer? I dislike leaving questions open. – BillHaggerty Apr 16 '15 at 13:15

1 Answers1

3

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.

Lloyd Pique
  • 916
  • 5
  • 5