Does the Android home screen widget support auto rotation?

I am working on widgets on the home screen. I hope this widget can support auto rotation. For example, if the phone is in portrait mode, I want this widget on the main screen to be 2 cells * 2 cells on the main screen; if the phone is in landscape mode, I want the widget changes on the main screen to be 3 cells * 1 cell on the main screen. Is it possible that I can do this?

Thanks.

+4
source share
2 answers

You can specify a different layout file in the / res / layout -land directory to give your widget a different layout when the main screen is in the layout orientation.

However, you cannot change from 2x2 to 3x1 to change the orientation, as this can very easily cause a conflict with other widgets / icons on the main screen.

To check the screen orientation change on the emulator, you can press the "Home" key on the numeric keypad of your computer keyboard ("7" on the numeric keypad with "Num Lock" turned off).

+5
source

You really can get a twist on the Droid, and I had to check this condition for some widgets. I think, however, that dimensions are not something that you can control, because then the widget may be too large in one orientation and widgets that can coexist in one orientation, invalid in another.

+2
source

Source: https://habr.com/ru/post/1303600/


All Articles