2012年5月20日 星期日

[AndroidLayout] Input Method Editors

若沒有做任何設定與調整,在輸入時所跳出的鍵盤(IMEs, Input Method Editors)很有可能會擋住正在輸入文字的元件,可以用以下方式處理:
  • 畫面中使用 scrollView,讓使用者可以自己適當的調整畫面位置。
  • 在該 activity 設 android:windowSoftInputMode ="adjustPan|adjustResize",讓系統幫忙處理。


android:windowSoftInputMode ="adjustPan"
  • Can prevent your background from resizing.
  • 不會呼叫 View.onSizeChanged()。
  • 不會調整 layout 所以不能保證能看到整個 layout 但會保持必能看到輸入框(平移)。
  • 設為 fullscreen 有時會使此參數失效,所以若是用 webview fullscreen 得注意。

android:windowSoftInputMode ="adjustResize"
  • 把原本的 layout(include background!) 往上頂,移出空間給 IME,但僅發生在 application 有可調整的空間。
  • 沒加此的話,不會一開啟就 focus on editText(?);加的話,一開啟就會 focus on 且有 soft input(?。
  • 會呼叫 View.onSizeChanged()。
  • 設為 fullscreen 有時會使此參數失效,所以若是用 webview fullscreen 得注意。


* Reference
- android:windowSoftInputMode
- Android Development Tips: Resizing layout while on-screen keyboard is displayed
- Issue 5497: adjustResize windowSoftInputMode breaks when activity is fullscreen
- Android windowSoftInputMode – Resize the application for the soft-keyboard
- Android: Soft Keyboard resizes background image
- android软键盘弹出引起的各种不适终极解决方案
- Android软键盘的隐藏显示研究 ***
- 关于android的输入法弹出来 覆盖输入框的问题
- Issue 14596: adjustPan not working correctly in landscape mode

沒有留言:

張貼留言