开发者

ReArrange UI on Android Phone on screen rotation

I am creating a Android app which shows a set of web pag开发者_如何学运维es dedicated web pages for the phone . Now , How do i target my pages for multiple screen sizes and also for example how to handle screen rotation that is the user tilts his phone and and and UI gets arranged. I use a WebView to display my web pages .

Thanks in Advance


You can create multiple layout folders in your res folder like this: layout-portrait, layout-landscape. Then you store different layouts in respective folders. Android is aware of what's the current orientation and it looks for a layout in the respective folder. Same way are the drawable-ldpi, drawable-mdpi and drawable-hdpi folders arranged. Hope this helps!


Each time the screen orientation is changing, the current activity in your app triggers the method onCreate(Bundle savedInstanceState) So you can decide to re-arrange your WebView by this way.

Then, detect the screen orientation : http://ykyuen.wordpress.com/2010/02/13/android-detect-the-phone-orientation/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜