Search code examples
androidandroid-edittextkeypad

Android keypad view is in front of the EditText when touched to edit


On Image 1 I have a layout with some textview and edittext controls, when the user touches any EditText of this particular layout (other activities doesn't have this issue) the keypad appears in front of the EditText control so the user cannot see what he is writing, this is weird, image 2 shows the problem. Here is my XML:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <EditText
            android:id="@+id/responsavelContratadaDiarioEditar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/TextView71"
            android:layout_marginBottom="10dp"
            android:ems="10"
            android:imeOptions="actionDone"
            android:singleLine="true" >

            <requestFocus />
        </EditText>

        <Button
            android:id="@+id/dataVistoriaDiarioEditar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/responsavelContratadaDiarioEditar"
            android:text="Data da Vistoria" />

        <TextView
            android:id="@+id/TextView81"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/dataVistoriaDiarioEditarTexto"
            android:text="Ponto de Controle"
            android:textSize="18sp"
            android:textStyle="bold" />

        <EditText
            android:id="@+id/pontoControleDiarioEditar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/TextView81"
            android:layout_weight="0.56"
            android:ems="10"
            android:gravity="top"
            android:imeOptions="actionDone"
            android:inputType="textMultiLine"
            android:maxLines="10"
            android:scrollbars="vertical"
            android:singleLine="false" />

        <TextView
            android:id="@+id/TextView71"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/projeto_spinnerDiarioEditar"
            android:text="Responsável contratada"
            android:textSize="18sp"
            android:textStyle="bold" />

        <Spinner
            android:id="@+id/projeto_spinnerDiarioEditar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/textView11"
            android:spinnerMode="dialog" />

        <TextView
            android:id="@+id/textView11"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="14dp"
            android:text="Projeto"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textSize="18sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/dataVistoriaDiarioEditarTexto"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/dataVistoriaDiarioEditar"
            android:layout_toRightOf="@+id/dataVistoriaDiarioEditar"
            android:clickable="false"
            android:text="23/12/1989" />

    </RelativeLayout>

</LinearLayout>

Image1 Image2

Thanks.


Solution

  • I added this code on my onCreate() method, after setContentView and it worked :)

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    

    Cya and thanks.