ScrollView拒绝滚动到底部

ScrollView拒绝滚动到底部

本文介绍了Android ScrollView拒绝滚动到底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有相关布局的根scrollview元素,并且在相对布局中有一堆表单元素.

I have a root scrollview element with a relativelayout in it, and a bunch of form elements inside the relative layout.

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

For some reason, when the soft keyboard is up it seems unable to scroll all the way to the bottom, which cuts one of my buttons in half.

这是层次结构查看器的屏幕快照,用于演示我的意思.

Here is a screenshot of the hierarchy viewer to demonstrate what I mean.

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

As you can see, the system knows that the view continues past the keyboard, yet the scrollview (which fills the visible part of the screen correctly) won't continue to scroll down as it should.

我在活动清单中有android:windowSoftInputMode="adjustResize",并且我可以/不会将其切换为平移.

I have android:windowSoftInputMode="adjustResize" in the manifest for the activity, and I can/will not switch it to pan.

感谢您的帮助.

edit:我在1个以上的视图中看到了这一点.这是另一个具有相同问题的视图的xml:

edit: I am seeing this in more than 1 view. Here is the xml of another view with the same problem:

<?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"引起的.一旦我将其取出,滚动条就可以正常工作了.

This is truly strange, but it seems to be caused by android:layout_margin="32dp" within the RelativeLayout. Once I took it out the scroll worked properly.

当然,由于这个原因,我不得不在表单元素上添加更多的页边距,但是至少现在这是固定的.

Of course, because of this I had to add a bunch more margins to my form elements, but at least this is now fixed.

这篇关于Android ScrollView拒绝滚动到底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 10:35