0

I'm trying to get the editTexts, and sign in button to move up when the software keyboard is out however I want the background to not be compressed(I'm going to add an image soon). I have the TextView(Login), two EditTexts(email and password) and signin button in a ScrollView because I thought that might help however I have not be able to figure anything out.

https://i.stack.imgur.com/4JMqM.png

https://i.stack.imgur.com/4JMqM.png

This is the xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" >

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_centerHorizontal="true"
            android:gravity="center"
            android:id="@+id/textLayout">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAppearance="?android:attr/textAppearanceLarge"
                android:text="Login"
                android:id="@+id/loginView"
                android:textSize="22dp"
                android:layout_above="@+id/textLayout"
                android:layout_centerHorizontal="true" />

            <EditText
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/emailTextfield"
                android:inputType="textEmailAddress"
                android:background="@android:drawable/edit_text"
                android:textColor="@android:color/primary_text_light"
                android:text="andresc1305@yahoo.com"
                android:hint="Email" />

            <EditText
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:inputType="textPassword"
                android:hint="Password"
                android:text="Andres123"
                android:background="@android:drawable/edit_text"
                android:textColor="@android:color/primary_text_light"
                android:ems="10"
                android:id="@+id/passwordTextfield" />

            <Button
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="SIGN IN"
                android:background="@android:color/transparent"
                android:textSize="24dp"
                android:id="@+id/signinButton"
                android:layout_below="@+id/textLayout"
                android:layout_centerHorizontal="true"
                android:onClick="onSigninClick"/>
        </LinearLayout>
    </ScrollView>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Forgot your password?"
        android:background="@android:color/transparent"
        android:textSize="14dp"
        android:id="@+id/forgotButton"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:onClick="onPasswordRecoverClick"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Register"
        android:background="@android:color/transparent"
        android:textSize="14dp"
        android:id="@+id/registerButton"
        android:layout_alignTop="@+id/forgotButton"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:onClick="onRegisterClick"/>


</RelativeLayout>
  • 2
    I think this [thread](http://stackoverflow.com/questions/1964789/move-layouts-up-when-soft-keyboard-is-shown) will answer your question #googlingIsHard – Mehmet K May 01 '15 at 15:57

3 Answers3

0

Look at this answer. In short, your problem can most likely be solved by setting the following in your AndroidManifest.xml inside the relevant activity or application element:

android:windowSoftInputMode="adjustResize"
Community
  • 1
  • 1
PPartisan
  • 8,173
  • 4
  • 29
  • 48
0

@PPartisan

This is without:

android:windowSoftInputMode="adjustResize"

https://i.stack.imgur.com/IXyTH.png

This is with:

https://i.stack.imgur.com/m2qdz.png

Beside the compression you can see my "Forgot your password" and "Register" buttons but I have those outside my ScrollView in the XML. Is there a way to scroll the LinearLayout (which contains the Login(TextView, email(EditText), password(EditText), and Signin(button) up when the software keyboard comes up?

The answer by zmilojko seems like what I want to do but he only says to add the ScrollView and not what to do after that has been added. Is there something I can place in the to make it move up when the software keyboard comes up?

0

see this thread, i think it can help you

layout of the screen moves up when keyboard is displayed

or just try to put this in your xml:

android:windowSoftInputMode="adjustPan" 

or this

android:windowSoftInputMode="adjustNothing"

Seems like it works different in each case.

Community
  • 1
  • 1
Ricardo A.
  • 685
  • 2
  • 8
  • 35