Android ScrollView 拒绝滚动到底部

标签 android android-layout scroll scrollview

我有一个包含相对布局的根 ScrollView 元素,以及相对布局内的一堆表单元素。

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

这是层次结构查看器的屏幕截图,以说明我的意思。

enter image description here

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

我在 Activity 的 list 中有 android:windowSoftInputMode="adjustResize",我可以/不会将其切换到平移。

感谢任何帮助。

编辑:我在不止 1 个 View 中看到这个。这是另一个有同样问题的 View 的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>

最佳答案

这确实很奇怪,但它似乎是由RelativeLayout 中的android:layout_margin="32dp" 引起的。一旦我把它拿出来,卷轴就可以正常工作了。

当然,因此我不得不为我的表单元素添加更多边距,但至少现在已修复。

关于Android ScrollView 拒绝滚动到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11660937/

相关文章:

html - 如何阻止用户在我的网站上水平滚动

javascript - ScrollTo... 如何滚动到 # 上方一定数量的像素?

android - 如何在 Android 应用程序中保留用户 Activity 日志?

android - 如何以编程方式关闭外部应用程序?

Android从java代码设置 TextView 颜色

java - 获取菜单组作为 View

Android 软键盘操作按钮

ios - 向下滚动时 UITableview 看不到最后一个单元格

android - Maven项目导入Eclipse后pom文件报错

java - android .getTop() 返回 0.0