首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >弹出软键盘时的页面滚动

弹出软键盘时的页面滚动
EN

Stack Overflow用户
提问于 2012-04-03 15:44:47
回答 10查看 127.8K关注 0票数 108

我有一个<ScrollView>布局:

代码语言:javascript
复制
<?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个输入栏和“确定”按钮,这是隐藏的软键盘,但页面不能滚动的。为什么?如何摆脱它?基本上,我希望看到每个输入框和“确定”按钮,甚至软键盘弹出。

EN

回答 10

Stack Overflow用户

发布于 2012-04-03 16:35:27

我通过在AndroidManifest.xml<activity>中定义以下属性修复了这个问题

代码语言:javascript
复制
android:windowSoftInputMode="adjustResize"
票数 132
EN

Stack Overflow用户

发布于 2014-02-27 01:22:38

好了,我已经找了几个小时来找问题了,我找到了。

fillViewport="true"android:windowSoftInputMode="adjustResize"这样的改变都没有帮到我。

我使用的是Android4.4,这是一个大错误

代码语言:javascript
复制
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

不知何故,当SoftKeyboard可见时,全屏主题会阻止ScrollViews滚动。

目前,我最终使用的是以下内容:

代码语言:javascript
复制
android:theme="@android:style/Theme.Black.NoTitleBar

我不知道如何摆脱顶部的系统条与时间和电池显示,但至少我得到了问题。

希望这对其他有同样问题的人有所帮助。

编辑:我为我的案例找到了一个解决办法,所以我把它贴到了here

我不确定这对你是否有效,但它肯定会帮助你理解,并澄清一些事情。

EDIT2: Here是另一个很好的话题,它将帮助你朝着正确的方向前进,甚至解决你的问题。

票数 39
EN

Stack Overflow用户

发布于 2016-02-12 01:20:01

对我来说,唯一能起作用的是放在这个属性的清单中的活动中:

代码语言:javascript
复制
android:windowSoftInputMode="stateHidden|adjustPan"

打开活动时不显示键盘,并且不与视图底部重叠。

票数 21
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9989130

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档