Android: EditText in ScrollView goes of the screen when kayboard appears

586 views Asked by At

I am trying to create a login screen. I have used ScrollView to hold input fields. I have following xml:

<RelativeLayout ... >
    <RelativeLayout
        android:id="@+id/top_menu" ... >
        <ImageButton ... />
        <com.neopixl.pixlui.components.textview.TextView... />
    </RelativeLayout>

    <ScrollView
        android:id="@+id/scroll_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/top_menu"
        android:overScrollMode="always">

        <LinearLayout
            android:id="@+id/login_group"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:orientation="vertical">

            <com.neopixl.pixlui.components.edittext.EditText
                android:id="@+id/user_name_email"
                android:layout_width="match_parent"
                android:layout_height="@dimen/input_height_size"
                android:layout_marginEnd="20dp"
                android:layout_marginStart="20dp"
                android:background="@drawable/edit_text_strock"
                android:hint="@string/user_Name_Email_EditText"
                android:maxLines="1"
                android:paddingLeft="10dp"
                android:paddingStart="10dp"
                android:textColor="@color/White"
                android:textColorHint="@color/White"
                android:textSize="@dimen/register_input_text_size"
                pixlui:typeface="MuseoSans.otf"/>

            <com.neopixl.pixlui.components.edittext.EditText.... />
            <com.neopixl.pixlui.components.button.Button... />
            <com.neopixl.pixlui.components.textview.TextView... />
            <com.neopixl.pixlui.components.textview.TextView... />
            <com.neopixl.pixlui.components.textview.TextView... />
            <com.neopixl.pixlui.components.button.Button... />
        </LinearLayout>
    </ScrollView>
</RelativeLayout>

You can see full xml here. When I click on EditText user_name_email, it goes off the screen.

Before click:

Before click

After click:

After click

I have tried scrollTo(x, y) and smootScrollTo(x, y) bu they didn't work.

How can I fix it?

UPDATE:

adjustPan works but I want it to work with adjustResize. Is it possible?

2

There are 2 answers

0
keshav kowshik On BEST ANSWER

Use the following line in the manifest file, for the activity you need the change.

android:windowSoftInputMode="adjustPan"

Use it as shown below:

<activity
            android:name=".ActivityName"
            android:label="title_for_activity"
            android:windowSoftInputMode="adjustPan" >
        </activity>

Hope this helps.

0
A.S On

add this to manifest file:

android:windowSoftInputMode="adjustPan"

in the targeted activity tag.