softInputMode- 软件盘的设置

今天遇到一个问题,就是软件盘弹出来以后,会把之前的布局界面整个的挤到屏幕的外面,而且按下返回建以后,这个软件盘占据的空间会留下一个黑色的背景。在网上查找了很多的方法,刚开始都是说,如下方法

 <activity

        android:label="@string/app_name"
        android:theme="@style/ComposeTheme"
        android:name="com.android.email.activity.ComposeActivityEmail"
        android:windowSoftInputMode="adjustPan" 
       android:configChanges
="keyboard|keyboardHidden|fontScale|orientation|screenSize">
android:windowSoftInputMode="adjustPan"这个属性就是设置软件盘的,他的值有9个,具体怎么使用,以后用到了再说,不过,它并没有解决我的问题

后来同事给我说了个方法,成功解决。就是在弹出软件盘所在的activity中,加入一个代码就行了
import android.view.WindowManager;




@Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.email_vip_activity); /* Vanzo:zhangshuli on: Thu, 15 Jan 2015 21:26:00 +0000 */ getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE_FULLSCREEN);//这一句是关键 // End of Vanzo: zhangshuli Intent i = getIntent(); mAccountId = i.getLongExtra(ACCOUNT_ID, -1); if (savedInstanceState == null && mAccountId != -1) { // First-time init; create fragment to embed in activity. FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment newFragment = VipListFragment.newInstance(mAccountId); ft.add(R.id.fragment_placeholder, newFragment); ft.commit(); } mActionBar = getActionBar(); // Configure action bar. mActionBar.setDisplayOptions( ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP); mActionBar.setDisplayShowCustomEnabled(true); mActionBar.setDisplayShowTitleEnabled(false); // Prepare the custom view mActionBar.setCustomView(R.layout.vip_actionbar_custom_view); mActionBarCustomView = (ViewGroup) mActionBar.getCustomView(); mVipMembers = (TextView)mActionBarCustomView.findViewById(R.id.vip_member); /** * M: When all accounts has been deleted, the vip list activity will be * finished and login page will be displayed. @{ */ if (mAccountObserver == null) { mAccountObserver = new AccountContentObserver(null, this); } getContentResolver().registerContentObserver(Account.NOTIFIER_URI, true, mAccountObserver); /** @} */ }
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE_FULLSCREEN);//这一句是关键

完美解决了问题。至于为什么加载AndoridManifest.xml中没有作用,现在还不知道



posted @ 2015-01-16 10:02  小白屋  阅读(914)  评论(0编辑  收藏  举报