1.在AndroidMainfest.xml中的對(duì)應(yīng)activity標(biāo)簽添加屬性
android:configChanges="orientation|keyboardHidden"
2.如果想dialog,fragment等也有此效果,可在oncreate()方法中添加
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
WindowManager.LayoutParams中還有很多有意思的屬性,有興趣的同學(xué)可以研究一下它的效果