The APP I am building has a login screen which has the logo, an edit text for the username, an edit text for the password and a button to login.
Previously I had a ScrollView and made both EditText singleline = true. So the user can type in details and hit next while typing. Then hit finish then select the login button OR swipe down to select login.
However the customer wants to remove the ScrollView from the login page. So that the button and two edit texts are always at the bottom, either at the bottom of the screen or above the keyboard if the keyboard is up.
I am able to keep the button on top but then the second EditText gets covered, or I have managed to keep both EditText on screen but then the button goes under screen. How do I stop the keyboard from covering the second EditText and button for my login page?
Below is my code:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/loginButton"
android:orientation="vertical"
android:layout_weight="1">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainLogoImageView"
android:src="@drawable/ic_logo_main"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_above="@+id/usernameEditText"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="false" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/usernameEditText"
android:hint="@string/username"
android:layout_alignParentLeft="true"
android:maxLines="1"
android:singleLine="true"
android:layout_alignParentRight="true"
android:layout_above="@+id/passwordEditText"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="@+id/passwordEditText"
android:hint="@string/password"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:singleLine="true"
android:layout_alignParentRight="true"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="0">
<ImageButton
android:layout_width="150dp"
android:layout_height="wrap_content"
android:src="@drawable/ic_signin"
android:text="Sign In"
android:id="@+id/loginButton"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:onClick="attemptLogin"
android:background="@color/orange_button_bg"
style="?android:attr/borderlessButtonStyle"
android:layout_gravity="center_horizontal"/>
</LinearLayout>
I had tried to use linear weighting from the advice from another forum question: - Push button above soft keyboard
If you have a similar problem these are some other questions that might be helpful: