Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android scrollview not scrolling down after keyboard opens

I have a textview that is inside of a scrollview, it scrolls fine untill the soft keyboard is opened.

When the keyboard is opened it act like it scrolled up again with the height of the keyboard.

What I have tried

I tried this in the manifest, but yielded the exact same results

android:windowSoftInputMode="adjustResize"

Then this:

android:windowSoftInputMode="adjustPan"

That seemed to work, but the problem was that it was moving the whole screen up and taking the header out of view.

I also tried adding the following in the linear layout

android:focusable="true"
android:focusableInTouchMode="true"

That only caused the app not to focus on the input field (EditText) and the keyboard didn't open automatically, but when you clicked on the input field it would just act the same as before.

This is the XML file code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightGray"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/bottom_layout"
    android:layout_marginTop="10dip" >

    <LinearLayout
        android:id="@+id/msg_list_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
    </LinearLayout>
</ScrollView>

<RelativeLayout
    android:id="@+id/bottom_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@android:color/background_light">
    <Button
        android:id="@+id/send_btn"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="@string/txt_send" />

    <EditText
        android:id="@+id/msg_edit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/send_btn"
        android:layout_toLeftOf="@+id/send_btn"
        android:inputType="text" >
    </EditText>
</RelativeLayout>

Any suggestions?

like image 940
Shaun Avatar asked Nov 23 '13 19:11

Shaun


1 Answers

I had same problem and the solutions is this: My activity was in fullscreen mode and scroll does not work in this mode this is a bug and we send a report to google. Just look at your activity in manifest if there is a fullscreen mode just remove it.

like image 84
HK.avdalyan Avatar answered Oct 20 '22 18:10

HK.avdalyan