Android ScrollView拒绝滚动到底部

Dog*_*oge 28 android scroll scrollview android-layout

我有一个根scrollview元素,其中包含一个relativelayout,以及相对布局中的一堆表单元素.

出于某种原因,当软键盘打开时,它似乎无法一直滚动到底部,这将我的一个按钮切成两半.

以下是层次结构查看器的屏幕截图,用于演示我的意思.

在此输入图像描述

如您所见,系统知道视图继续通过键盘,但滚动视图(正确填充屏幕的可见部分)将不会继续向下滚动.

我有android:windowSoftInputMode="adjustResize"活动的清单,我可以/不会把它切换到平底锅.

任何帮助表示赞赏.

编辑:我在多个视图中看到这个.这是另一个具有相同问题的视图的xml:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/background" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="32dp" >
        <EditText
            android:id="@+id/reset_oldpass"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:ems="10"
            android:singleLine="true"
            android:hint="@string/current_password"
            android:layout_marginTop="16dp" />
        <EditText
            android:id="@+id/reset_pass1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/reset_oldpass"
            android:ems="10"
            android:hint="@string/reset_new_pass"
            android:inputType="textPassword"
            android:layout_marginTop="16dp" />
        <EditText
            android:id="@+id/reset_pass2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/reset_pass1"
            android:ems="10"
            android:hint="@string/reset_confirm_pass"
            android:inputType="textPassword"
            android:layout_marginTop="16dp" />
        <TextView
            android:id="@+id/reset_forgot_password"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/reset_pass2"
            android:layout_marginTop="16dp"
            android:textColor="@color/Link"
            android:textStyle="bold"
            android:text="@string/Login_forgot_password" />
        <Button
            android:id="@+id/reset_reset_password_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/reset_forgot_password"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="16dp"
            android:layout_marginBottom="32dp"
            android:text="@string/reset_change_pass" />
    </RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

Dog*_*oge 40

这真的很奇怪,但它似乎是由android:layout_margin="32dp"RelativeLayout 引起的.一旦我拿出它,滚动工作正常.

当然,因为这个我必须在我的表单元素中添加更多的边距,但至少现在已经修复了.

  • 这是真的.如果ScrollView内的布局有边距,则无法一直滚动到底部.对于我的情况,我可以将边距放在根布局中,因为我有一个包含滚动视图和按钮的LinearLayout. (3认同)

Ion*_*gru 13

我遇到了同样的问题,我通过在ScrollView中使用填充而不是在RelativeLayout中使用边距来修复它.

因此,android:layout_margin="32dp"从RelativeLayout(ScrollView的子节点)中删除并添加android:padding="32dp"到ScrollView.