键盘启动时Android ScrollView不滚动

标签 android keyboard scrollview

我有一个没有填满屏幕的 View ,但是当键盘出现时,您不能向下滚动到现在覆盖的几个字段。我尝试在 list 和类中添加adjustSize、adjustPan。 xml 类似于以下条目:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/s"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    >

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/TableLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <!-- TextViews & EditTexts are here -->
    </TableRow>
        <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <!-- TextViews & EditTexts are here -->
    </TableRow>
        <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <!-- TextViews & EditTexts are here -->
    </TableRow>
        <TableRow
        android:id="@+id/tableRow4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <!-- TextViews & EditTexts are here -->
    </TableRow>
        <TableRow
        android:id="@+id/tableRow5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <!-- TextViews & EditTexts are here -->
    </TableRow>



</TableLayout>
</ScrollView>

当键盘出现时,我需要能够滚动浏览editTexts和TextViews

最佳答案

Flipbed 的链接提供的是您的解决方案的答案。如果您只是将“adjustResize”添加到 list 中的 Activity ,则无需实现解决方法。您之前遇到的问题是您使用的是adjustPan。在 adjustPan 不调整窗口大小的地方,它平移 View ,以便任何有焦点的东西都不会被软键盘遮挡。如果您查看 Google 的文档(请参阅下面的链接),这将是有意义的。

例子:

<activity android:name="YourActivity" 
          android:windowSoftInputMode="adjustResize" />

http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

关于键盘启动时Android ScrollView不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17556334/

相关文章:

android - 如何将谷歌地图 View 放在底部工具栏的正上方?

android - 使用什么 Android 表单 Controller 来选择大范围的数字

android - crosswalk cordova android 更新项目?

ios - scrollview 在访问 View Controller 的最后一个组件时向上滚动

安卓模拟器 : Easy way to simulate a process restart due to low memory?

c# - 启动期间在 Main-Method 中获取 WPF 应用程序中的键盘状态

iOS 在搜索栏外部点击时关闭键盘

c - 从用户级别禁用键盘设备

android - ImageView 很慢

android - 将 LinearView 和 ExpandableListView 放入 ScrollView 是否可能且有效