0
A
回答
0
不它有助於:
setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
Log.i(TAG,"Enter pressed");
}
return false;
}
});
0
的活動:
final View activityRootView = findViewById(R.id.activityRoot);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
activityRootView.getWindowVisibleDisplayFrame(r);
int heightDiff = view.getRootView().getHeight() - (r.bottom - r.top);
if (heightDiff > 100) {
//enter code when show keyboard
}else{
//enter code when hide keyboard
}
}
});
對於片段:
view = inflater.inflate(R.layout.live_chat_fragment, null);
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
//r will be populated with the coordinates of your view that area still visible.
view.getWindowVisibleDisplayFrame(r);
int heightDiff = view.getRootView().getHeight() - (r.bottom - r.top);
if (heightDiff > 500) { // if more than 100 pixels, its probably a keyboard...
//enter code when show keyboard
}else{
//enter code when hide keyboard
}
}
});
相關問題
- 1. 軟鍵盤聽衆
- 2. JavaFX全局鍵盤監聽器
- 3. 鍵盤事件監聽器在JavaScript
- 4. 用Java Applet實現鍵盤監聽器
- 5. ActionScript3外部類鍵盤監聽器
- 6. Android軟件菜單鍵監聽器是否存在?
- 7. Android上的全局鍵盤輸入監聽器
- 8. Android虛擬鍵盤和監聽器恢復值?
- 9. 如何在Perl中實現鍵盤監聽器或動作監聽器
- 10. Android監聽器中斷監聽器
- 11. Android的軟鍵盤
- 12. Android軟鍵盤 - 需要Android軟鍵盤的源代碼AOSP
- 13. 隱藏android軟鍵盤當軟鍵盤按一鍵時
- 14. 鍵盤快捷鍵和動作監聽器
- 15. 谷歌鍵盤輸入鍵監聽器不工作
- 16. fabric.js畫布監聽鍵盤事件?
- 17. Android-gps監聽器
- 18. 傾聽完成不關閉軟鍵盤
- 19. JNA:鍵監聽器+ JFrame
- 20. 背景按鍵監聽器
- 21. c#propertyGrid鍵監聽器
- 22. 中文Android軟鍵盤
- 23. 軟輸入鍵盤與Android
- 24. Android軟鍵盤示例
- 25. 與軟鍵盤的Android
- 26. Android軟鍵盤隱藏RecyclerView
- 27. Android軟鍵盤覆蓋EditText?
- 28. onClick控制軟鍵盤 - Android
- 29. Android上的軟鍵盤
- 30. Android軟鍵盤問題
謝謝你,但仍然未能 – shucc
@ChenChao你可以請提供全部鍵盤屏幕截圖? –