Android 如何使EditText像Google keep应用程序一样工作(平滑滚动,不被输入法覆盖)?

Android 如何使EditText像Google keep应用程序一样工作(平滑滚动,不被输入法覆盖)?,android,android-edittext,scrollview,Android,Android Edittext,Scrollview,我有一个带有片段的活动,在片段中有一个EditText,我希望能够写几行文本,但软件键盘会在EditText增长时覆盖它 我见过ScrollView、adjustResize和adjustPan的用法,但我不知道它们为什么不起作用 更新: 如果我使用.beginTransaction().add它可以正常工作,但我需要使用.beginTransaction().replace和键盘盖EditText 更新2: 它在安卓4.3上运行良好 但在安卓4.4中,键盘盖EditText 我想要的是: 出现

我有一个带有片段的活动,在片段中有一个
EditText
,我希望能够写几行文本,但软件键盘会在
EditText
增长时覆盖它

我见过
ScrollView
adjustResize
adjustPan
的用法,但我不知道它们为什么不起作用

更新: 如果我使用
.beginTransaction().add
它可以正常工作,但我需要使用
.beginTransaction().replace
和键盘盖
EditText

更新2: 它在安卓4.3上运行良好 但在安卓4.4中,键盘盖
EditText

我想要的是:
  • 出现在键盘上方的
    布局(包含编辑文本)
  • 在该布局中平滑滚动

  • 要强制显示软键盘,可以使用

    EditText yourEditText= (EditText) findViewById(R.id.yourEditText);
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT);
    
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);
    
    要关闭它,您可以使用

    EditText yourEditText= (EditText) findViewById(R.id.yourEditText);
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT);
    
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);
    

    希望它能对您有所帮助。

    根据,通过在根元素上设置android:fitsSystemWindows=“true”,它工作正常

    使用半透明系统栏时会出现很多问题。我有一个类似的问题,我找到了0个解决方案。尝试移除半透明的系统栏,检查它是否工作正常。

    这不是我的意思。我的问题是,当键盘出现时,它会覆盖EditText。在清单文件中,您需要设置相应的android:WindowsOfInputMode属性。此属性自API 3起有效。我见过adjustResize和adjustPan的用法,但我不知道它们为什么不起作用!我很快就会把密码寄出去。请在清单活动标记中使用