0

I have a layout where i have one image view, two edittext and one button, when i clicked on the first edittext, i can't scroll to the second to fill it too, because of the virtual keyboard, here is my 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:gravity="center_horizontal" >

    <ImageView
        android:id="@+id/logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:src="@drawable/logo"
        android:contentDescription="@string/invokeme" />

    <EditText
        android:id="@+id/login"
        android:layout_height="wrap_content"
        android:layout_width="235dip"
        android:ems="10"
        android:layout_marginTop="25dp"
        android:layout_below="@id/logo"
        android:hint="@string/login" />
    <EditText
        android:id="@+id/password"
        android:inputType="textPassword"
        android:layout_height="wrap_content"
        android:layout_width="235dip"
        android:ems="10"
        android:layout_marginTop="5dp"
        android:layout_below="@id/login"
        android:hint="@string/password" />
    <Button 
        android:id="@+id/submitLogin"
        android:layout_width="235dip"
        android:layout_height="wrap_content"
        android:ems="12"
        android:text="@string/login"
        android:layout_below="@id/password"/>



</RelativeLayout>
Mike Mertsock
  • 11,825
  • 7
  • 42
  • 75

1 Answers1

0

There might be more than one way around. First one may be that you can keep everything ( the whole relative layout) inside a ScrollView. Second way can be that you may establish a touch listener on your view, excluding the two EditText's. When anything other than those two EditText is touched, you can hide the keyboard from the screen. See How to hide soft keyboard on android after clicking outside EditText? for more. Hope it helps.

Community
  • 1
  • 1
Shobhit Puri
  • 25,769
  • 11
  • 95
  • 124