T
T
Terroris3372021-09-23 14:28:17
Android
Terroris337, 2021-09-23 14:28:17

How to move the interface elements when the keyboard appears?

Good day. Tell me how to shift elements when the keyboard appears.

My Activity:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/mainColor"
    tools:context=".MainActivity">


    <android.support.constraint.ConstraintLayout
        android:id="@+id/group_807"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="327.23dp"
        android:layout_marginEnd="66dp"
        android:layout_marginStart="45dp"
        android:layout_marginTop="130dp"
        android:background="@color/group_807"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

    </android.support.constraint.ConstraintLayout>

    <com.github.mmin18.widget.RealtimeBlurView
        android:id="@+id/realtimeBlurView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:realtimeBlurRadius="100dp" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="292dp"
        android:layout_height="292dp"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="452dp"
        android:layout_marginEnd="42dp"
        android:layout_marginStart="42dp"
        android:layout_marginTop="85dp"
        android:contentDescription="@string/character"
        android:src="@mipmap/ic_launcher_foreground"
        app:layout_constraintBottom_toBottomOf="@+id/main"
        app:layout_constraintEnd_toEndOf="@+id/main"
        app:layout_constraintHorizontal_bias="0.485"
        app:layout_constraintStart_toStartOf="@+id/main"
        app:layout_constraintTop_toTopOf="@+id/main" />

    <android.support.constraint.ConstraintLayout
        android:id="@+id/loginText"
        android:layout_width="251dp"
        android:layout_height="72dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="62dp"
        android:layout_marginStart="62dp"
        android:layout_marginTop="30dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/imageView2"
        app:layout_constraintVertical_bias="0.0">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginBottom="48dp"
            android:layout_marginEnd="21dp"
            android:layout_marginStart="21dp"
            android:fontFamily="sans-serif"
            android:gravity="center_horizontal|top"
            android:text="@string/login_text"
            android:textColor="@color/login_text_color"
            android:textSize="20sp"
            android:textStyle="bold"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_marginEnd="21dp"
            android:layout_marginStart="21dp"
            android:layout_marginTop="32dp"
            android:fontFamily="sans-serif"
            android:gravity="center_horizontal|top"
            android:lineSpacingExtra="3sp"
            android:text="@string/login_text_details"
            android:textAppearance="@style/you_can_sen"
            android:textColor="@color/login_text_details_color"
            android:textSize="14sp"
            android:textStyle="normal"
            android:translationY="-1.33sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>

    <EditText
        android:layout_width="342dp"
        android:layout_height="56dp"
        android:layout_marginBottom="240dp"
        android:layout_marginEnd="17dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="475dp"
        android:background="@drawable/edit_style"
        android:hint="@string/email_hint"
        android:inputType="textEmailAddress"
        android:paddingEnd="0dp"
        android:paddingStart="29dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/editText"
        android:layout_width="342dp"
        android:layout_height="56dp"
        android:layout_marginBottom="172dp"
        android:layout_marginEnd="17dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="537dp"
        android:background="@drawable/edit_style"
        android:hint="@string/password_hind"
        android:inputType="textPassword"
        android:paddingEnd="0dp"
        android:paddingStart="29dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:layout_width="342dp"
        android:layout_height="56dp"
        android:layout_marginBottom="100dp"
        android:layout_marginEnd="17dp"
        android:layout_marginStart="16dp"
        android:layout_marginTop="609dp"
        android:background="@drawable/button_style"
        android:text="@string/login_button"
        android:textColor="@color/button_test_color"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>


In AbdroidManifest.xml I wrote android:windowSoftInputMode="adjustResize" , it seems like I'm trying to move something, but in the end I get this result:
614c64345e213970414659.jpeg

It should be something like this:
614c644e3ce32460788659.png

What's the problem? Possibly a crooked layout?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmtm, 2021-09-24
@Dmtm

as an option - track the keyboard and change the layout entirely

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question