Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ScrollView refuses to scroll to bottom

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.

enter image description here

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.

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

Any help is appreciated.

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> 
like image 450
Doge Avatar asked Jul 26 '12 01:07

Doge


People also ask

How do I scroll to the bottom of the page on Android?

Make sure the webpage is long enough so that the browser shows a scroll bar. Once there, to get to the bottom of the page, simply tap the top right corner on your device. In the screenshot below, I need to tap the area where the time is shown. The page will automatically scroll all the way down to the bottom.

Why is ScrollView not scrolling?

To fix ScrollView Not scrolling with React Native, we wrap the content of the ScrollView with the ScrollView. to wrap ScrollView around the Text components that we render inside. As a result, we should see text inside and we can scroll up and down.


1 Answers

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.

like image 168
Doge Avatar answered Sep 27 '22 19:09

Doge