弹出软键盘时页面滚动 [英] Page scroll when soft keyboard popped up
问题描述
我有一个<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>
如上所示,简单的布局由三个输入字段和一个确定"按钮组成.
As you see above, the simple layout consists of three input fields and an "Ok" button.
我使用上述布局运行我的应用,当我点击第一个输入字段(@+id/input_one
)时,软键盘将从屏幕底部弹出,它隐藏第三个输入字段和确定"按钮.
I run my app with the above layout, when I tap on the 1st input field (@+id/input_one
), the soft keyboard will pop up from the bottom of the screen, it hides the 3rd input field and the "Ok" button.
由于我使用了<ScrollView>
,所以我想可以向上滚动页面以查看第三个输入字段和确定"按钮,这些字段被软键盘隐藏了,但是该页面不可滚动.为什么?如何摆脱它? 基本上,我希望看到每个输入字段和确定"按钮,即使弹出的软键盘也是如此.
Since I use <ScrollView>
, I thought I can scroll the page up in order to see the 3rd input field and "Ok" button which are hidden by the soft keyboard, but the page is not scrollable. Why? How to get rid of it? basically, i would like to see every input fields and "Ok" button even the soft keyboard popped up.
推荐答案
我通过在 AndroidManifest.xml
android:windowSoftInputMode="adjustResize"
这篇关于弹出软键盘时页面滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!