Search code examples
androidscrollview

Cannot scroll content inside LinearLayout when keyboard is shown


I'm using a background image inside ScrollView which already has the image in the background. I want the content inside LinearLayout to be scrollable and the background image should not shrink. This is my xml file :-

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/login_background"
android:fillViewport="true"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.appzoy.croatiaapp.LoginActivity">

<LinearLayout
    android:id="@+id/email_login_form"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="50dp"
    android:gravity="bottom"
    android:orientation="vertical">

    <EditText
        android:id="@+id/userId"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:background="@drawable/user_name_background"
        android:hint="@string/hint_name"
        android:paddingBottom="15dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:paddingTop="15dp" />

    <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginTop="30dp"
        android:background="@drawable/user_name_background"
        android:hint="@string/hint_password"
        android:inputType="textPassword"
        android:paddingBottom="15dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:paddingTop="15dp" />

    <Button
        android:id="@+id/email_sign_in_button"
        android:layout_width="140dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="30dp"
        android:background="@drawable/login_button_background"
        android:enabled="false"
        android:gravity="center"
        android:text="@string/action_sign_in"
        android:textColor="@color/textColor"
        android:textSize="20sp" />

</LinearLayout>
</ScrollView>

I have used stateVisible|adjustPan as windowSoftInputMode attribute values.


Solution

  • you can try by keeping only attribute adjustPan

     <application
       android:windowSoftInputMode="adjustPan"/>