我有一个<ScrollView>
布局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_scrollview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="@+id/input_one"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<EditText
android:id="@+id/input_two"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<EditText
android:id="@+id/input_three"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:inputType="number" >
<Button
android:id="@+id/ok_btn"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="@string/ok_str" />
</LinearLayout>
</ScrollView>
正如您在上面看到的,这个简单的布局由三个输入字段和一个"Ok“按钮组成。
我用上面的布局运行我的应用程序,当我点击第一个输入栏(@+id/input_one
)时,软键盘将从屏幕底部弹出,它会隐藏第三个输入栏 "Ok“按钮。
由于我使用<ScrollView>
,我认为我可以滚动页面向上,以看到第3个输入栏和“确定”按钮,这是隐藏的软键盘,,但页面不能滚动的。为什么?如何摆脱它?基本上,我希望看到每个输入框和“确定”按钮,甚至软键盘弹出。
发布于 2012-04-03 16:35:27
我通过在AndroidManifest.xml的<activity>
中定义以下属性修复了这个问题
android:windowSoftInputMode="adjustResize"
发布于 2014-02-27 01:22:38
好了,我已经找了几个小时来找问题了,我找到了。
像fillViewport="true"
或android:windowSoftInputMode="adjustResize"
这样的改变都没有帮到我。
我使用的是Android4.4,这是一个大错误
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
不知何故,当SoftKeyboard可见时,全屏主题会阻止ScrollViews滚动。
目前,我最终使用的是以下内容:
android:theme="@android:style/Theme.Black.NoTitleBar
我不知道如何摆脱顶部的系统条与时间和电池显示,但至少我得到了问题。
希望这对其他有同样问题的人有所帮助。
编辑:我为我的案例找到了一个解决办法,所以我把它贴到了here上
我不确定这对你是否有效,但它肯定会帮助你理解,并澄清一些事情。
EDIT2: Here是另一个很好的话题,它将帮助你朝着正确的方向前进,甚至解决你的问题。
发布于 2016-02-12 01:20:01
对我来说,唯一能起作用的是放在这个属性的清单中的活动中:
android:windowSoftInputMode="stateHidden|adjustPan"
打开活动时不显示键盘,并且不与视图底部重叠。
https://stackoverflow.com/questions/9989130
复制相似问题