答案 0 :(得分:1)
从清单文件中删除此行。
android:windowSoftInputMode="adjustPan"
答案 1 :(得分:0)
试试这个:
添加java类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_edit_name, container);
editText = (EditText) view.findViewById(R.id.txt_yourName);
// Request focus and show soft keyboard automatically
editText.requestFocus();
getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
return view;
}
另一种解决方案
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
editText.post(new Runnable() {
@Override
public void run() {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
}
});
editText.requestFocus();