Как переместить всю раскладку над мягкой клавиатурой в android? - PullRequest
0 голосов
/ 19 июня 2020

Я, хочу реализовать такую ​​функциональность, как будто всякий раз, когда моя программная клавиатура открывается, вся моя раскладка будет выше этой клавиатуры в android. Я уже погуглил и нахожу подходящие ответы по этому поводу. Но это не соответствует моим ожиданиям.

Я добавил это в свой манифест: android: windowSoftInputMode = "adjustResize". Но это только ограниченная раскладка над клавиатурой. Я хочу, чтобы вся моя раскладка располагалась над клавиатурой.

Ниже приведены некоторые изображения для лучшего представления ...

Как вы можете видеть на изображении, моя клавиатура выходит за раскладку. Я хочу, чтобы весь мой макет означал, что кнопка регистрации не окажется над программной клавиатурой.

As you can see in image my keyboard is coming over the layout. I want that my whole layout means till the Register Button will come above the soft-keyboard.

Ниже мой XML Код:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:gravity="center"
    xmlns:app="http://schemas.android.com/apk/res-auto">

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

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Welcome,"
            android:textAlignment="center"
           />

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Register to Get Your Grocery Store Online"
            android:textAlignment="center"
            />

    </LinearLayout>

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/storeName"
            style="@style/TextInputLayoutStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewLabel"
           >

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Store Name"
                />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/storeLocationPinCode"
            style="@style/TextInputLayoutStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewLabel"
            >

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Store Location PinCode"
                 />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/storeCity"
            style="@style/TextInputLayoutStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewLabel"
           >

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Store City"
               />

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

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/storeState"
            style="@style/TextInputLayoutStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewLabel"
            >

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Store State"
               />

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


        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/storeAddress"
            style="@style/TextInputLayoutStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewLabel"
            >

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Store Address"
                />
        </com.google.android.material.textfield.TextInputLayout>

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/minimumAmount"
            style="@style/TextInputLayoutStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewLabel"
            >

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

        <com.google.android.material.textfield.TextInputLayout
            android:id="@+id/deliveryCharges"
            style="@style/TextInputLayoutStyle"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textViewLabel"

            >

            <com.google.android.material.textfield.TextInputEditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Delivery Charges"
                />
        </com.google.android.material.textfield.TextInputLayout>

        <Button
            android:id="@+id/registerMerchant"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="Register"
            android:layout_marginTop="65dp"
            android:layout_marginBottom="65dp"
           />


    </LinearLayout>
    </ScrollView>
</LinearLayout>

Ответы [ 2 ]

1 голос
/ 19 июня 2020

В вашем случае, я думаю, что adjustPan лучше, чем adjustResize, он sh обновит весь ваш макет.

adjustResize зависит от параметров макета, если вы используете ConstraintLayout, только просмотры ограничивают снизу вниз родительского элемента.

<activity android:windowSoftInputMode="adjustPan"/>
0 голосов
/ 19 июня 2020

Попробуйте добавить

<activity android:windowSoftInputMode="adjustResize"/>

в свою активность в файле манифеста

...