android:configChanges="orientation|keyboardHidden|screenSize"真的能固定屏幕吗
2016-08-19 10:43
495 查看
之前固定屏幕一直用的
与
今天在activity改变配置销毁重启与被系统杀死重启时,看见很多人说android:configChanges="orientation|keyboardHidden|screenSize"可以固定屏幕
而我在Activity源码中看到了这么一段话
然而我把那三个配置写上去的时候,事实证明除了能接受到
android:screenOrientation="portrait"
与
android:screenOrientation="landscape"
今天在activity改变配置销毁重启与被系统杀死重启时,看见很多人说android:configChanges="orientation|keyboardHidden|screenSize"可以固定屏幕
而我在Activity源码中看到了这么一段话
/** * Called by the system when the device configuration changes while your * activity is running. Note that this will <em>only</em> be called if * you have selected configurations you would like to handle with the * {@link android.R.attr#configChanges} attribute in your manifest. If * any configuration change occurs that is not selected to be reported * by that attribute, then instead of reporting it the system will stop * and restart the activity (to have it launched with the new * configuration). * * <p>At the time that this function has been called, your Resources * object will have been updated to return resource values matching the * new configuration. * * @param newConfig The new device configuration. */ public void onConfigurationChanged(Configuration newConfig) { if (DEBUG_LIFECYCLE) Slog.v(TAG, "onConfigurationChanged " + this + ": " + newConfig); mCalled = true; mFragments.dispatchConfigurationChanged(newConfig); if (mWindow != null) { // Pass the configuration changed event to the window mWindow.onConfigurationChanged(newConfig); } if (mActionBar != null) { // Do this last; the action bar will need to access // view changes from above. mActionBar.onConfigurationChanged(newConfig); } }
然而我把那三个配置写上去的时候,事实证明除了能接受到
onConfigurationChanged回调后吊用没有,试了一个4.4一个5.1系统都还是转来转去,但是却并没有重启 没有重新调用onCreate和onDestroy方法 。。 原因现在还不清楚,,群众中间有坏人啊 人云亦云的扯淡
相关文章推荐
- android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
- 纵横屏幕 不重启Oncreate android:configChanges="keyboardHidden|orientation"
- 关于android:configChanges="keyboardHidden|orientation"
- android屏幕翻转不重新加载android:configChanges="orientation|keyboardHidden"
- 横竖屏切换时,禁止activity重新创建,android:configChanges="keyboardHidden|orientation" 不起作用
- 什么时候使用 android:configChanges="keyboardHidden|orientation"
- android:configChanges="orientation|keyboardHidden“后横竖屏切换任然会销毁旧的activity然后创建新的
- 横竖屏切换时,禁止activity重新创建,android:configChanges="keyboardHidden|orientation" 不起作用
- andriod 4.0以上版本添加了 android:configChanges="keyboardHidden|orientation"不调用onConfigrationChange方法的解决办法
- android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
- 添加了android:configChanges="orientation|keyboardHidden|keyboard"属性后切屏时还是重刷了当前Activity?
- android:configChanges="keyboardHidden|orientation" 失效 Android横竖屏切换时生命周期都执行
- 关于android:configChanges="keyboardHidden|orientation"
- 横竖屏切换时,禁止activity重新创建,android:configChanges="keyboardHidden|orientation" 不起作用
- 关于android:configChanges="keyboardHidden|orientation"
- android4.0 禁止横竖屏切换使用 android:configChanges="orientation|keyboardHidden"无效
- android4.0 禁止横竖屏切换使用 android:configChanges="orientation|keyboardHidden"无效
- android:configChanges="orientation|keyboardHidden"的使用
- android4.0 禁止横竖屏切换使用 android:configChanges="orientation|keyboardHidden"无效的解决方法
- android4.0 禁止横竖屏切换使用 android:configChanges="orientation|keyboardHidden"无效