Does Android home screen widget support auto rotation?
I am working on a home screen widget. I hope this widget can support auto rotation. For example, if the phone is in portrait mode, I want this home screen widget to be 2 cell * 2 cell on the home screen; if the phone is in lands开发者_如何学运维cape mode, I want this home screen widget changes be 3 cell * 1 cell on the home screen. Is it possible that I can make it?
Thanks.
You can specify a different layout file in the /res/layout-land directory to give your widget a different layout when the home screen is in layout orientation.
However you can't change from 2x2 to 3x1 on orientation change, as this could very easily cause a conflict with other widgets/icons on the home screen.
To test screen orientation change on the emulator you can press the 'Home' key on the number pad of your computer's keyboard ('7' on the number pad with 'Num Lock' turned off).
You actually CAN get rotation on the Droid and I have had to test that condition for some widgets. I think however, that the dimensions are not something you can control because then a widget could be made too large in one orientation and widgets which could co-exist in one orientation invalid in the other.
精彩评论