⑴ 如何實現監聽android輸入法彈出收回,為什麼
在輸入法彈出的時候,後面的內容不會縮放;而評論輸入框剛好顯示在輸入法面板上(above)。
這里不僅需要監聽到輸入法的彈出和關閉,還要獲取到輸入法的高度。
如果發現輸入法沒有彈出了,那麼onMeasure就直接用傳進來的參數調用。
如果發現輸入法彈出了,那麼更改參數,保證View沒有縮小。
⑵ android輸入法是怎樣調用的
Android軟鍵盤強制彈出及隱藏輸入法的方法:
很多應用中對於一個界面比如進入搜索界面或者修改信息等等情況,為了用戶體驗應該自動彈出軟鍵盤而不是讓用戶主動點擊輸入框才彈出(因為用戶進入該界面必然是為了更改信息)。具體實現這種效果的代碼如下:
java代碼
EditText editText.setFocusable(true);
editText.setFocusableInTouchMode(true);
editText.requestFocus();
InputMethodManager inputManager =
(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(editText, 0);
首先要對指定的輸入框請求焦點。然後調用輸入管理器彈出軟鍵盤。
警告:對於剛跳到一個新的界面就要彈出軟鍵盤的情況上述代碼可能由於界面為載入完全而無法彈出軟鍵盤。此時應該適當的延遲彈出軟鍵盤如998毫秒(保證界面的數據載入完成)。實例代碼如下:
java代碼:
Timer timer = new Timer();
timer.schele(new TimerTask()
{
public void run()
{
InputMethodManager inputManager =
(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(editText, 0);
}
},
998);
⑶ android怎麼獲取屏幕高度,除去輸入法鍵盤佔用的那些
用InputViewManager.getCurrentView當前view,然後調用view中的void getBoundsOnScreen(Rect outRect)獲得大小
用這個方法試試
⑷ android 中如何獲取系統中安裝的所有輸入法並以列表顯示
private void onCreateIMM() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethodProperties = imm.getInputMethodList();
mLastInputMethodId = Settings.Secure.getString(getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD);
PreferenceGroup textCategory = (PreferenceGroup) findPreference("text_category");
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties
.size());
for (int i = 0; i < N; ++i) {
InputMethodInfo property = mInputMethodProperties.get(i);
String prefKey = property.getId();
CharSequence label = property.loadLabel(getPackageManager());
boolean systemIME = isSystemIme(property);
// Add a check box.
// Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
chkbxPref.setKey(prefKey);
chkbxPref.setTitle(label);
textCategory.addPreference(chkbxPref);
mCheckboxes.add(chkbxPref);
}
// If setting activity is available, add a setting screen entry.
if (null != property.getSettingsActivity()) {
PreferenceScreen prefScreen = new PreferenceScreen(this, null);
String settingsActivity = property.getSettingsActivity();
if (settingsActivity.lastIndexOf("/") < 0) {
settingsActivity = property.getPackageName() + "/" + settingsActivity;
}
prefScreen.setKey(settingsActivity);
prefScreen.setTitle(label);
if (N == 1) {
prefScreen.setSummary(getString(R.string.onscreen_keyboard_settings_summary));
} else {
CharSequence settingsLabel = getResources().getString(
R.string.input_methods_settings_label_format, label);
prefScreen.setSummary(settingsLabel);
}
textCategory.addPreference(prefScreen);
}
}
}
⑸ android 怎麼獲得輸入法整個布局的尺寸和坐標呢
獲得屏幕尺寸的話是:
DisplayMetrics dm = new DisplayMetrics();
//獲取窗口屬性
getWindowManager().getDefaultDisplay().getMetrics(dm);
int screenWidth = dm.widthPixels;
int screenHeight = dm.heightPixels;
⑹ android 點擊EditText後,設置彈出的輸入法高度
你可以 參考一下 InputMethodService這個類的介面。 大部分對輸入法的操作都可以通過它來完成。
⑺ android如何獲取輸入法高度,急!!!
什麼叫輸入法高度,是大小吧。。。
⑻ 如何獲取搜狗輸入法鍵盤高度
搜狗輸入法鍵盤高度設置如下:
1、首先要把搜狗輸入法升級到最新版本才可以自定義鍵盤的高度的
2、在輸入法界面,點設置圖標,如下圖
⑼ android 有沒有獲取系統軟鍵盤的高度的方法
沒有直接獲得的方法,貌似有種從根layout高度來減的方法間接獲得,不過我沒試過。
⑽ Android 如何實現在隱藏鍵盤後,讓輸入框保持當前高度,類似QQ、微信聊天窗口。
當editText獲取焦點的時候,需要直接調用顯示鍵盤命令:<pre t="code" l="java">editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
});