【发布时间】:2014-03-28 19:23:18
【问题描述】:
我有一个简单的布局,如下所示:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="200dp"
android:fadeScrollbars="false"
android:gravity="center_vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.2" />
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<EditText
android:layout_width="match_parent"
android:layout_height="290dp"
android:ems="10"
android:gravity="top" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Submit"/>
</LinearLayout>
</RelativeLayout>
基本上,ScrollView 内有一个 TextView 表示一个问题,我希望用户在 EditText 内输入答案。
在我的AndroidManifest 中,我添加了以下内容:
<activity
android:screenOrientation="portrait"
android:windowSoftInputMode="???" >
</activity>
“???”是,我尝试过使用以下内容:adjustPan、adjustResize 和 adjustPan|adjustResize。
使用adjustPan 和adjustResize,我遇到了同样的事情:当我输入文本时,屏幕会自动向下滚动,因此键盘不会覆盖正在输入的文本。然而,这里的问题是,当我尝试突出显示键入的文本以全选、复制、剪切或粘贴时,通常出现在顶部的复制/剪切/粘贴菜单栏无法访问,因为它已被滚动出去看法。如果我尝试手动到达该菜单栏,则文本不再突出显示。
使用adjustPan|adjustResize,复制/剪切/粘贴菜单栏始终保持在可视范围内且触手可及,但如果我输入太多,输入的文本最终会被键盘遮挡。
那么我怎样才能在输入的文本永远不会被遮挡的地方继续输入,并且仍然有复制/剪切/粘贴菜单栏跟随并允许我根据需要进行偶尔的编辑?
【问题讨论】:
标签: java android xml menu window-soft-input-mode