设为首页 加入收藏

TOP

Android 横竖屏和布局问题(二)
2014-11-23 22:06:57 来源: 作者: 【 】 浏览:29
Tags:Android 横竖 布局 问题
ystem.out(18936): ------ TestActivity onStart------
07-24 08:54:26.079: I/System.out(18936): ------ TestActivity onRestoreInstanceState------
07-24 08:54:26.079: I/System.out(18936): ------ TestActivity onResume------


c.再切换回竖屏的情况下:


07-24 08:55:02.099: I/System.out(18936): ------ TestActivity onPause------
07-24 08:55:02.109: I/System.out(18936): ------ TestActivity onSaveInstanceState------
07-24 08:55:02.119: I/System.out(18936): ------ TestActivity onStop------
07-24 08:55:02.129: I/System.out(18936): ------ TestActivity onDestroy------
07-24 08:55:02.139: D/memalloc(18936): /dev/pmem: Unmapping buffer base:0x5c7c5000 size:4608000 offset:3072000
07-24 08:55:02.139: D/memalloc(18936): /dev/pmem: Unmapping buffer base:0x5cc30000 size:9216000 offset:7680000
07-24 08:55:02.179: I/System.out(18936): ------ TestActivity onCreate------
07-24 08:55:02.249: I/System.out(18936): ------ TestActivity onStart------
07-24 08:55:02.289: I/System.out(18936): ------ TestActivity onRestoreInstanceState------
07-24 08:55:02.309: I/System.out(18936): ------ TestActivity onResume------


发觉上面的结果是跟网上的朋友说的不是一样的,原来是有区别的。


到后来去网上搜索了一下资料发觉,到了。4.0以后。要加上这样的配置才会使Activity的生命周期不会重新被调用


3)配置android:configChanges="keyboardHidden|orientation|screenSize" (4.0以后)


a.正常情况下:


07-24 08:54:05.059: I/System.out(18936): ------ TestActivity onCreate------
07-24 08:54:05.199: I/System.out(18936): ------ TestActivity onStart------
07-24 08:54:05.219: I/System.out(18936): ------ TestActivity onResume------



b.切换横屏情况下:


07-24 09:08:21.639: I/System.out(19533): ------ TestActivity onConfigurationChanged------


c.再切换回竖屏的情况下:


07-24 09:08:21.639: I/System.out(19533): ------ TestActivity onConfigurationChanged-----


总结:要想Activity在横竖屏切换的时候不重新加载生命周期的重要方法,一定要加上配置


4.0之前



android:configChanges="orientation|keyboardHidden"


>


4.0之后



android:configChanges="keyboardHidden|orientation|screenSize"


>


------------------------------------------------------常用设置---------------------------------------------------------


1.如果你的app指定要横屏显示的话



android:screenOrientation="portrait"


>


2.如果你的app指定要竖屏显示的话



android:screenOrientation="landscape"


>


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇创建 AngularJS 自定义过滤器,带.. 下一篇Android APP 登陆模块

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: