2013-03-16 108 views
0

我使用的是2個FrameLayout,它們都有EditText,如果我點擊editText在佈局的底部可以看到softKeyboard的上方,但是如果我點擊editBox的frameLayout是在其他FrameLayout位置不會更改並放置在鍵盤後面,並且位於底部的frameLayout會再次更改其位置並顯示在軟鍵盤上方。把EditText放在軟鍵盤上面

我試過,

mMessageBox.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
    @Override 
    public void onFocusChange(View v, boolean hasFocus) { 
     Commons.logCatchya("onFocusListener changed !"); 
     if (hasFocus) { 
      Commons.logCatchya("onFocusListener hasFocus !"); 
     } 
     else { 
      Commons.logCatchya("onFocusListener do not hav focus !"); 
     } 
    } 
}); 

mMessageBox.setOnKeyListener(new View.OnKeyListener() { 

    @Override 
    public boolean onKey(View v, int keyCode, KeyEvent event) { 
     Commons.logCatchya("setOnKeyListener :" + event.getAction() + " keyCode :" + keyCode); 
     return false; 
    } 
}); 


mProfileStatusBox.setOnFocusChangeListener(new View.OnFocusChangeListener() { 

    @Override 
    public void onFocusChange(View v, boolean hasFocus) { 
     Commons.logCatchya("onFocusListener mProfileStatusBox changed !"); 
     if (hasFocus) { 
      Commons.logCatchya("onFocusListener mProfileStatusBox hasFocus !"); 
     } 
     else { 
      Commons.logCatchya("onFocusListener mProfileStatusBox do not hav focus !"); 
     } 

    } 
}); 

,但如果我點擊隱藏屏幕上的軟鍵盤按鈕,光標仍然在我使用了編輯框。這是因爲FrameLayout的問題嗎?我不應該怎麼做才能解決這個問題。

回答

1

我用RelativeLayout和使用

android:gravity="bottom" 
在佈局文件

解決了這個問題。

1

設置此爲您的活動的活動標籤

android:configChanges="keyboardHidden|orientation" 

,如果它不爲你工作嘗試滾動型設置你的父母佈局

1

我敢肯定你使用0​​設置其widthheightfull_parent
不要這樣,使用RelativeLayout而不是設置height到:

android:layout_height="wrap_content"