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中没有作用,现在还不知道



转载于:https://www.cnblogs.com/zhangshuli-1989/p/zhangshuli_softkey_15011610.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值