我有这个页面:
但是,当打开softWareKeyBoard
我看不到其他EditText
。我能做什么?
注意:我使用下面的代码,但没有奏效。而我class
是extends Fragment
!
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
有两种方法可以做到这一点无论您可以在清单活动使用
它会为工作,调整锅将向上流动的表面,并打开软键盘
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
<activity android:name="XXXActivity" android:windowSoftInputMode="adjustPan">
</activity>
工作守则
对于片段:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
对于活动:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
我用这样的以编程方式显示软键盘,这是为我工作,以防止屏幕的自动调整,同时推出的键盘。
EditText et = (EditText))findViewById(R.id.edit_text);
Timer timer = new Timer();
TimerTask task = new TimerTask() {
@Override
public void run() {
InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(et.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
};
timer.schedule(task, 200);
在清单文件的使用:
<activity android:name="XXXActivity" android:windowSoftInputMode="adjustPan">
</activity>