направление компоновки ограничений изменяется при отображении программной клавиатуры

#android #android-softkeyboard #android-constraintlayout #android-layout-direction

#Android #android-программная клавиатура #android-constraintlayout #android-layout-direction

Вопрос:

В моем приложении есть проблема с компоновкой ограничений и программной клавиатурой. Я изменил направление компоновки для всего приложения из style, добавив <item name="android:layoutDirection">rtl</item> внутри темы приложения по умолчанию. Но это влияет на направление компоновки ограничений при отображении программной клавиатуры. смотрите рисунки ниже.

прежде чем коснуться редактирования текста:

введите описание изображения здесь

после касания редактировать текст:

введите описание изображения здесь

Я пробовал:

  1. различная комбинация android:windowSoftInputMode="adjustPan|stateAlwaysHidden|stateHidden" в манифесте.

  2. добавление android:layoutDirection="ltr" к параметру компоновки ограничений.

 <androidx.cardview.widget.CardView 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="180dp"
    android:layout_alignParentBottom="true"
    android:layout_gravity="center_horizontal"
    android:layout_marginLeft="@dimen/recycle_margin"
    android:layout_marginTop="30dp"
    android:layout_marginRight="@dimen/recycle_margin"
    android:layout_marginBottom="@dimen/recycle_margin_half"
    android:foreground="?attr/selectableItemBackground"
    app:cardCornerRadius="@dimen/card_border"
    app:cardElevation="@dimen/card_elevation">
    <!--TODO: maximum width-->

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="10dp">

        <androidx.constraintlayout.widget.Guideline
            android:id="@ id/dl_header"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            app:layout_constraintGuide_percent="0.2" />

        <ImageView
            android:id="@ id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:scaleType="fitStart"
            app:layout_constraintBottom_toTopOf="@ id/dl_header"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/shetab" />

        <TextView
            android:id="@ id/card_pan_mask"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/credc"
            android:text="6104 33** **** 7928"
            android:textDirection="ltr"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@ id/card_exp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/credc"
            android:text="61/22"
            android:textDirection="ltr"
            app:layout_constraintBottom_toTopOf="@id/card_name"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toBottomOf="@id/card_pan_mask" />

        <TextView
            android:id="@ id/cvv2_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/credc"
            android:text="CVV:"
            android:textDirection="ltr"
            app:layout_constraintBottom_toTopOf="@id/card_name"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/card_pan_mask" />

        <EditText
            android:id="@ id/card_cvv2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/credc"
            android:background="@drawable/date_shape"
            android:text="6103"
            android:textDirection="ltr"
            android:paddingHorizontal="10dp"
            android:paddingVertical="5dp"
            app:layout_constraintBottom_toTopOf="@id/card_name"
            app:layout_constraintStart_toEndOf="@ id/cvv2_text"
            app:layout_constraintTop_toBottomOf="@id/card_pan_mask" />

        <EditText
            android:id="@ id/card_name"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@drawable/date_shape"
            android:layoutDirection="rtl"
            android:maxLines="1"
            android:paddingHorizontal="10dp"
            android:paddingVertical="5dp"
            android:text="متن تست"
            android:textDirection="rtl"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent" />


    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>