键盘启动时,Android ScrollView不会滚动

Bil*_*nic 17 keyboard android scrollview

我的视图没有填满屏幕,但是当键盘出现时,您无法向下滚动到现在覆盖的几个字段.我尝试在清单和类中添加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>
Run Code Online (Sandbox Code Playgroud)

我需要能够在键盘出现时滚动editTexts和TextViews

ken*_*ggy 44

Flipbed提供的链接是您解决方案的答案.如果只是在清单中为活动添加"adjustResize",则无需实施解决方法.您之前遇到的问题是您使用的是adjustPan.如果adjustPan没有调整窗口的大小,它会平移视图,这样任何具有焦点的东西都不会被软键盘遮挡.如果您查看Google的文档(请参阅下面的链接),这将是有意义的.

例:

<activity android:name="YourActivity" 
          android:windowSoftInputMode="adjustResize" />
Run Code Online (Sandbox Code Playgroud)

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

  • 不,没有用.添加它会自动向下移动底部按钮....我不想要这个.我只是想在滚动时让它可见.键盘打开后不会立即打开. (4认同)
  • @kenodoggy对不起,我尝试了这个,但是不起作用:( (2认同)