Space between Edittext and keyboard on android

Asked

Viewed 1,173 times

6

I wonder if it is possible to put a margin to space the edittext keyboard so it is not so close:

inserir a descrição da imagem aqui

The xml of how I am declaring Edittext:

        <EditText
        android:id="@+id/editTextNome"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:layout_marginLeft="23px"
        android:layout_marginRight="23px"
        android:paddingLeft="7dp"
        android:layout_marginBottom="40dp"
        android:hint="@string/nome_login"
        android:inputType="textCapSentences"
        android:background="@drawable/rounded_border"/>

2 answers

3


Have you ever tried to set your android:windowSoftInputMode as follows:

android:windowSoftInputMode="adjustResize"

or

android:windowSoftInputMode="adjustPan"

by definition, according to the documentation,

adjustResize: The main activity window is always resized to create space for the software keyboard on the screen.

adjustPan: The main window of the activity is not resized to create space for the software keyboard on the screen. Instead, you move the contents of the window automatically so that the current focus is never overlaid by the keyboard and users can always see what they type. Typically, this behavior is less desirable than resizing, as the user may need to close the software keyboard to access and interact with the overlapping parts of the window.

But from the context, I believe that in your case adjustResize work, if it doesn’t work, arrow on Activity android:windowSoftInputMode="adjustPan", along with a android:paddingBottom in the EditText, with the value it deems necessary and arrow also: android:gravity="bottom".

0

Thanks @Mathias, the adjustResize worked well, it follows how it got all the xml of the field if serve as reference for someone:

in the manifest file:

<activity android:name=".MainActivity" android:windowSoftInputMode="adjustResize|stateAlwaysHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

and in the xml of Activity:

<LinearLayout
    android:id="@+id/menu_login"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="100dp"
    android:orientation="vertical"
    android:visibility="invisible"
    android:layout_marginBottom="35dp">
    <EditText
        android:id="@+id/editTextNome"
        android:layout_width="match_parent"
        android:layout_marginLeft="20px"
        android:layout_marginRight="20px"
        android:paddingLeft="5dp"
        android:layout_marginBottom="35dp"
        android:hint="@string/nome_login"
        android:layout_height="40dp"
        android:inputType="textCapSentences"
        android:background="@drawable/rounded_border"
    />
    <Button
        android:id="@+id/botaoEntrar"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="@string/botao_entrar"
        android:elevation="0dp"
        android:background="@drawable/rounded_button"
        android:textColor="@color/white"
        android:onClick="abrirFicha"
    />
</LinearLayout>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.