2012-12-05 54 views
0

我无法看到,当我键入EDITTEXT控制,因为软键盘掩盖了(隐藏)EDITTEXT控制代码示例如下:如何以编程方式更改LinearLayout的位置?

private LinearLayout.LayoutParams LY_Scroll = new LinearLayout.LayoutParams(
      LayoutParams.FILL_PARENT, 388); 
    private LinearLayout.LayoutParams LY_BOTTOM = new LinearLayout.LayoutParams(
      LayoutParams.FILL_PARENT, 45); 
    private LinearLayout.LayoutParams LY_EDIT = new LinearLayout.LayoutParams(
      267, LayoutParams.FILL_PARENT); 
    private LinearLayout.LayoutParams LY_BTN = new LinearLayout.LayoutParams(
      LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); 
    private LinearLayout.LayoutParams LY_TEXT = new LinearLayout.LayoutParams(
      LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); 


@Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     LinearLayout layout_all = new LinearLayout(this); 
     layout_all.setOrientation(LinearLayout.VERTICAL); 
     layout_all.setBackgroundColor(android.graphics.Color.WHITE); 

     // top 
     setContentView(layout_all); 

     sv = new ScrollView(this); 
     sv.setLayoutParams(LY_Scroll); 

     text_Show = new TextView(this); 
     text_Show.setLayoutParams(LY_TEXT); 
     sv.addView(text_Show); 

     // bottom 
     LinearLayout layout_bottom = new LinearLayout(this); 
     layout_bottom.setLayoutParams(LY_BOTTOM); 
     layout_bottom.setOrientation(LinearLayout.HORIZONTAL); 

     editText = new EditText(this); 
     editText.setLayoutParams(LY_EDIT); 

     sendBtn = new Button(this); 
     sendBtn.setLayoutParams(LY_BTN); 
     sendBtn.setText("Send"); 

     layout_bottom.addView(editText); 
     layout_bottom.addView(sendBtn); 

     layout_all.addView(sv); 
     layout_all.addView(layout_bottom); 

     ........ 
    } 

可以在任何一个有想法如何使EDITTEXT可见当我输入在软键盘?

由于事先

回答

0

这样看来,最好的办法是使用windowSoftInputMode来控制你的对话框应该如何工作。也许你想要adjustPan选项,尽管文档建议不要使用它。见this earlier answer

0

将这添加到您的清单下,您有EditText的活动。

android:windowSoftInputMode="adjustPan" 
相关问题