本帖最后由 hfqandroid 于 2012-05-11 16:54:26 编辑

解决方案 »

  1.   

    方法:1、获取你这个布局的view对像,假设名称为view1;2、获取第二个文本框的点击事件,在点击事件里面加入以下代码:InputMethodManager imm = ((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE));
    imm.updateCursor(view1, 0, -200, 0, 0);上面代码的-200是top位置减200,也就是改变view1的位置,使其往上移,以实现你要的效果。
      

  2.   

    楼上方法有误,改为:1、首先获取布局界面的Layout对像,假设名称为FrameLayout01;
     
    声明全局对象private FrameLayout FrameLayout01;
     
    并获取这个对象
     
    FrameLayout01 = (FrameLayout) findViewById(R.id.FrameLayout01);
     
     
     
    2、监听输入框文本框的事件,假设文本框的对象名称为password,代码:
     password.setOnFocusChangeListener(new OnFocusChangeListener()
             {
        @Override
        public void onFocusChange(View arg0, boolean arg1) {
         // TODO Auto-generated method stub
         if(arg1)
         {
          LayoutParams lp = (LayoutParams) FrameLayout01.getLayoutParams();
          lp.setMargins(0, -320, 0, 0);
          FrameLayout01.setLayoutParams(lp);
         }
         else
         {
          LayoutParams lp = (LayoutParams) FrameLayout01.getLayoutParams();
          lp.setMargins(0, 0, 0, 0);
          FrameLayout01.setLayoutParams(lp);
         }
        }
      });
     上面代码的-320是top位置减320,也就是改变FrameLayout01的位置,使其往上移,通过改变top的值来实现不被软键盘遮住的效果。