软键盘重叠多行编辑文本



我在ScrollView中有多行EditText。我需要在显示键盘时使整个EditText可见。现在它与EditText的底部重叠,仅显示第一行。 我已经在这里阅读了很多问题,尝试了adjustPan/adjustResize组合等,但没有什么真正有帮助。

<EditText
android:id="@+id/et_feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:lines="8"
android:maxLines="10"
android:minLines="6"
android:padding="10dp"
android:gravity="top|left"
android:inputType="textMultiLine"
android:background="@drawable/et_bg"
android:scrollbars="vertical" />

AndroidManifest.xml中:

<activity
android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="adjustResize"
...

windowSoftInputMode是关键,但我个人也发现了configChanges帮助。

以及有关处理输入法可见性的更多信息

使用以下XML 代码进行编辑文本:

<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"/> 

将所有视图放在顶级 ScrollView 中,以便在屏幕没有您显示的高度时可以滚动内容。出于一般布局目的而假设屏幕的高度不是一个好主意。如果您希望内容在所有屏幕大小、方向和键盘状态上都可滚动,请始终使用 ScrollView。

最新更新