2

Tengo mi activityMain en donde tengo un login sencillo, en este al abrir el teclado para ingresar los datos se superpone el teclado sobre el campo de password y no deja hacer scroll por lo que estuve viendo como solucionarlo pero ahroa se mueve nada mas lo que queda debajo del teclado y se pone encima de la demás vista y se ve mal, no se si lo estoy haciendo mal o hay alguna otra manera.

Así se ve normal sin abrir el teclado

Vista principal

Así se veía antes de hacer los cambios, el teclado se superpone a los componentes

Sin corrección

Así se ve con los cambios

Con las correcciones

Lo que hice fue colocar dos lineas de código que teoría iban a funcionar

android:windowSoftInputMode="adjustResize">
android:fitsSystemWindows="true"

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.ValetParking">
        <activity android:name=".login.ChangePasswordActivity" />
        <activity android:name=".login.ForgotPasswordActivity" />
        <activity android:name=".login.LocationActivity" />
        <activity android:name=".login.AboutThePlaceActivity" />
        <activity android:name=".login.CreateAccountActivity" />
        <activity android:name=".TabLayoutOperatorActivity" />
        <activity android:name=".TabLayoutAdministratorActivity" />
        <activity android:name=".Operator.CloseTicket" />
        <activity android:name=".Operator.ProfileOperatorActivity" />

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

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

    <!-- Google maps -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="------------------------------------" />
</application>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:fitsSystemWindows="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <!-- Background -->
    <View
        android:id="@+id/background"
        style="@style/background" />

    <!-- Background title -->
    <View
        android:id="@+id/background_title"
        android:layout_width="match_parent"
        android:layout_height="133dp"
        android:background="@drawable/background_title" />

    <!-- Title -->
    <TextView
        android:id="@+id/title"
        style="@style/title"
        android:layout_marginTop="30dp"
        android:text="@string/login_title" />

    <!-- Title icon -->
    <View
        android:id="@+id/title_icon"
        android:layout_width="155dp"
        android:layout_height="104dp"
        android:layout_below="@+id/background_title"
        android:layout_centerHorizontal="true"
        android:background="@drawable/title_icon" />

    <!-- Title info -->
    <TextView
        android:id="@+id/title_info"
        style="@style/message"
        android:layout_below="@id/title_icon"
        android:layout_marginBottom="50dp"
        android:text="@string/login_info_title"
        android:clickable="true"/>


    <!-- Username -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/login_username"
        style="@style/text_input_layout"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:hint="@string/create_account_username"
        app:startIconDrawable="@drawable/ic_person">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/login_username_edit"
            style="@style/text_input_edit_text"
            android:inputType="text" />
    </com.google.android.material.textfield.TextInputLayout>

    <!-- Password -->
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/login_password"
        style="@style/text_input_layout"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_below="@id/login_username"
        android:hint="@string/create_account_password"
        app:endIconMode="password_toggle"
        app:startIconDrawable="@drawable/ic_lock">

        <com.google.android.material.textfield.TextInputEditText
            android:id="@+id/login_password_edit"
            style="@style/text_input_edit_text"
            android:inputType="textPassword" />
    </com.google.android.material.textfield.TextInputLayout>

    <!-- Remember me -->
    <CheckBox
        android:id="@+id/remember_me_checkbox"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:layout_marginLeft="20dp"
        android:layout_below="@id/login_password"
        android:buttonTint="@color/black" />

    <TextView
        android:id="@+id/remember_me_checkbox_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_below="@id/login_password"
        android:layout_toRightOf="@id/remember_me_checkbox"
        android:clickable="true"
        android:text="@string/remember_me" />

    <!-- Forgot password -->
    <TextView
        android:id="@+id/forgot_password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginRight="20dp"
        android:layout_below="@id/login_password"
        android:layout_alignParentRight="true"
        android:clickable="true"
        android:text="@string/forgot_password" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="50dp"
        android:orientation="vertical">

        <!-- Button -->
        <Button
            android:id="@+id/button_login"
            style="@style/button"
            android:text="@string/button_login" />

        <!-- Create account -->
        <TextView
            android:id="@+id/create_account"
            style="@style/message"
            android:clickable="true"
            android:text="@string/login_create_account" />
    </LinearLayout>
</RelativeLayout>
3
  • Agrega más código, no veo ahí los edittexts, ni el botón ni nada
    – Osdward
    el 4 ago. 2021 a las 15:45
  • Buenas amigo! Ya lo he agregado el 4 ago. 2021 a las 16:12
  • Si te hago un diseño nuevo usando LinearLayout en ves de de RelativeLayout, lo usarías si resuelve tu problema? o prefieres usar RelativeLayout?
    – Osdward
    el 4 ago. 2021 a las 20:43

2 respuestas 2

2

Te hice un diseño nuevo y es adaptativo [MARCALA COMO RESPONDIDA SI TE SIRVE]

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


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:text="VALET PARKING"
        android:textColor="@color/Negro"
        android:textSize="40sp"
        android:textStyle="bold" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="20dp"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/imageView3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:ignore="ImageContrastCheck"
        tools:srcCompat="@tools:sample/avatars" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:id="@+id/textView4"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:singleLine="false"
        android:text="Inicie sesion y maneje sus autos y bla bla blablabla"
        android:textColor="@color/Negro"
        android:textSize="20sp" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <com.google.android.material.textfield.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center">

        <androidx.appcompat.widget.AppCompatEditText
            android:id="@+id/email"
            android:layout_width="300dp"
            android:layout_height="40dp"
            android:focusableInTouchMode="true"
            android:hint="correo"
            android:imeOptions="actionUnspecified"
            android:inputType="textEmailAddress"
            android:padding="5dp"
            android:paddingStart="20dp"
            android:paddingTop="10dp"
            android:paddingEnd="20dp"
            android:paddingBottom="10dp"
            android:singleLine="true"
            tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck"/>


    </com.google.android.material.textfield.TextInputLayout>


    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/etPasswordLayout1"
        card_view:passwordToggleEnabled="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center">

        <androidx.appcompat.widget.AppCompatEditText
            android:id="@+id/password"
            card_view:passwordToggleEnabled="true"
            android:layout_width="300dp"
            android:layout_height="40dp"
            android:focusableInTouchMode="true"
            android:hint="password"
            android:imeOptions="actionUnspecified"
            android:inputType="textPassword"
            android:padding="5dp"
            android:paddingStart="20dp"
            android:paddingTop="10dp"
            android:paddingEnd="20dp"
            android:paddingBottom="10dp"
            android:singleLine="true"
            tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck"/>


    </com.google.android.material.textfield.TextInputLayout>


</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="horizontal">


    <CheckBox
        android:id="@+id/checkBox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingStart="0dp"
        android:paddingEnd="10dp"
        android:text="Recordarme"
        android:textColor="@color/Negro"
        android:textColorHighlight="@color/Verde"
        android:textColorLink="@color/Verde"
        tools:ignore="TouchTargetSizeCheck" />


    <TextView
        android:id="@+id/reset_pass"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:text="Olvidaste tu pass?"
        android:textColor="@color/Negro" />


</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:gravity="center"
    android:orientation="vertical">

    <Button
        android:id="@+id/login"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:text="iniciar sesion"
        android:textAllCaps="false"
        android:textColor="@color/Negro"
        android:textSize="16sp" />


   </LinearLayout>

   <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:orientation="vertical">

    <TextView
        android:id="@+id/textView6"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="Crear cuenta"
        android:textColor="@color/Negro"
        android:textSize="18sp" />
      </LinearLayout>


    </LinearLayout>

introducir la descripción de la imagen aquí

1
  • Si funciona, muchísimas gracias, voy a analizar el código para comprenderlo mejor y saberlo aplicar el 9 ago. 2021 a las 14:37
0

debes utilizar "adjustPan" el adjustResize no siempre funciona, salvo que tengas trabajado los temas asociados a distintos tama;os... ver el siguiente https://developer.android.com/guide/topics/manifest/activity-element?hl=es-419#wsoft

1
  • 1
    Si bien este enlace puede responder a la pregunta, es mejor incluir las partes esenciales de la respuesta aquí y proporcionar el enlace como referencia. Las respuestas que son únicamente un enlace pueden dejar de ser válidas si la página vinculada cambia. - Desde revisión
    – padaleiana
    el 10 jul. a las 11:10

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.