Android Studio - keyboard is superimposed on the components of the activity

0

I have an activity that is a registration form that takes up the whole screen (fullscrean)

but when the keyboard appears it covers the components that are at the end

I put a scrollview to my activities but I also can not get the components to dislise upwards when the keyboard appears and I also swear that in the manifest I already tried with all the attributes of the windowSoftInputMode and I did not works with none:

android:windowSoftInputMode="probe con todos los atributos"

to scrollview also probe placing the attribute of:

android:fillViewport="true"

and it does not work either, unless I'm making a bad combination of containers, but someone to help me please.

These are my activities:

activity_form_registro.xml

<android.support.design.widget.CoordinatorLayout
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"
tools:context=".FormulariosdeRegistro.FormRegistro">

<include layout="@layout/form_registro"/>

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|right"
    android:layout_margin="@dimen/fab_margin"
    android:src="@drawable/ic_forward_white_24dp"/>

</android.support.design.widget.CoordinatorLayout>

form_register.xml

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal|center_vertical"
tools:showIn="@layout/activity_form_registro">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="280dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="center_horizontal">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp"
            android:layout_marginBottom="3dp">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/textInputLayoutPrimerNombre"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:counterEnabled="true"
                app:counterMaxLength="20">

                <EditText
                    android:id="@+id/editTextPrimerNombre"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Primer Nombre *"
                    android:inputType="text" />
            </android.support.design.widget.TextInputLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp"
            android:layout_marginBottom="3dp"
            android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/textInputLayoutSegundoNombre"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:counterEnabled="true"
                app:counterMaxLength="20">

                <EditText
                    android:id="@+id/editTextSegundoNombre"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Segundo Nombre"
                    android:inputType="text" />
            </android.support.design.widget.TextInputLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp"
            android:layout_marginBottom="3dp"
            android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/textInputLayoutApellidoPaterno"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:counterEnabled="true"
                app:counterMaxLength="20">

                <EditText
                    android:id="@+id/editTextApellidoPaterno"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Apellido Paterno"
                    android:inputType="text" />
            </android.support.design.widget.TextInputLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="3dp"
            android:layout_marginBottom="3dp"
            android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                android:id="@+id/textInputLayoutApellidoMaterno"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:counterEnabled="true"
                app:counterMaxLength="20">

                <EditText
                    android:id="@+id/editTextApellidoMaterno"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Apellido Materno"
                    android:inputType="text" />
            </android.support.design.widget.TextInputLayout>
        </LinearLayout>

    </LinearLayout>

</ScrollView>

</LinearLayout>
    
asked by Leonidas 17.10.2018 в 20:44
source

2 answers

0

What I can think of first of all is to capture the onCLick event of the editText components and, at the time of execution, move the whole view that you include upwards.

The ScrollView only allows scrolling when the layout it contains exceeds the dimensions of the parent container. The keyboard is not part of the activity that you visualize, so although it seems that there are too many elements on the screen, the ScrollView functionality is not activated.

    
answered by 17.10.2018 в 22:13
0

As I see the layout is well-armed, there is a very clean way to solve this problem without having to touch the layout a lot

First let's set in the Manifest windowSoftInputMode="adjustResize" this will make the container (the windows) of the activity is adjusted leaving room for the keyboard.

Inside the manifest you have to put this:

<activity
   android:windowSoftInputMode="adjustResize"
   .../>

So this is what you already tried and it did not work out, that's because you're missing a final detail and it's the fitsSystemWindows in the Activity's layout. This will make changing your Windows size your Activity to that new size.

<android.support.design.widget.CoordinatorLayout
   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:fitsSystemWindows="true"
   tools:context=".FormulariosdeRegistro.FormRegistro">

With this it should be enough for the screen to be trimmed when the keyboard appears. But remember that it is essential that you have a good scroll to avoid problems.

There are other ways to solve the problem without having to cut the screen, sometimes it may be to add empty space to the ScrollView so you can access what is under the keyboard. But that alone I would recommend it in very particular cases of design.

    
answered by 17.10.2018 в 23:07