0

Доброго дня! Никак не могу адекватно решить такую проблему:

Есть у меня экран с EditText'ами в слое ScrollView, а в самом низу стоит кнопка и всё это в LinearLayout.

Открываю клавиатуру по нажатию на один из editText и эта кнопка снизу встаёт над открытой клавиатурой и собой перекрывает другие EditText'ы.

Так вот вопрос, как не сдвигать кнопку вверх при открытии клавиатуры, но чтобы остальные элементы сдвигались?

С манифестом работал методом тыка(stateHidden чтоб изначально клавы небыло): android:windowSoftInputMode="stateHidden|adjustResize"

android:windowSoftInputMode="stateHidden|adjustPan"

При 2м варианте кнопка не поднимается, но и слой с EditText'ами не поднимается.

Код манифеста

<activity android:name=".activities.OrderScreenActivity"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateHidden|adjustResize"/>

Код экрана

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

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_order"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

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

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:padding="16dp"
        android:weightSum="1">

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/til_name_act_order"
            android:layout_marginBottom="8dp">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/ed_name_act_order"
                android:hint="Имя"
                android:textColor="@color/text_color_353535"
                android:imeOptions="actionNext"
                android:inputType="text" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Телефон"
                android:id="@+id/ed_tel_act_order"
                android:inputType="phone"
                android:maxLength="17"
                android:textColor="@color/text_color_353535"
                android:digits="0,1,2,3,4,5,6,7,8,9"
                android:imeOptions="actionNext" />

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

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Адрес"
                android:id="@+id/ed_address_act_order"
                android:textColor="@color/text_color_353535"
                android:inputType="text"
                android:imeOptions="actionNext" />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp">

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Комментарии"
                android:id="@+id/ed_comment_act_order"
                android:textColor="@color/text_color_353535"
                android:inputType="textMultiLine" />

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

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/tv_summ_act_order"
            android:textColor="@color/text_color_353535"
            android:textSize="18sp"
            android:text=" Общая сумма: "
            android:layout_marginTop="4dp" />

    </LinearLayout>
</ScrollView>

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

    <ProgressBar
        style="?android:attr/progressBarStyle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/progressBar_act_order"
        android:visibility="gone" />

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/height_border_line_item"
        android:background="@color/color_border_item" />

    <Button
        android:text="Оформить"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btn_send_order_act_order"
        android:background="@drawable/bg_selector_order"
        android:textColor="@drawable/btn_order_text_color" />
</LinearLayout>

Скрины того, как сейчас работает

тут фокусируемся при переходах editText'ы смещаются при скрытии клавы кнопка наконец встаёт вниз

Специально поставил поля ввода в ScrollView, так как поле комментария увеличивается и может быть растянуто на весь экран, а кнопка должна быть постоянно на экране.

Менял ScrollView на FrameLayout и переносил слой с кнопкой внутрь с gravity: bottom, но тогда слой также перекрывает, но прозрачным становится.

В общем, хочу смещать только слой с полями ввода, но чтоб слой с кнопкой не сдвигался и не перекрывал поля ввода, как на скринах

1 ответ 1

3

Посмотрел, как решили мою проблему с FrameLayout на en.SO. В общем, сменил слои и свойство в манифесте:

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

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_order"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

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

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1">

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

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:padding="16dp"
            android:weightSum="1">

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/til_name_act_order"
                android:layout_marginBottom="8dp">

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/ed_name_act_order"
                    android:hint="Имя"
                    android:textColor="@color/text_color_353535"
                    android:imeOptions="actionNext"
                    android:inputType="text" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp">

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Телефон"
                    android:id="@+id/ed_tel_act_order"
                    android:inputType="phone"
                    android:maxLength="17"
                    android:textColor="@color/text_color_353535"
                    android:digits="0,1,2,3,4,5,6,7,8,9"
                    android:imeOptions="actionNext" />

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

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp">

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Адрес"
                    android:id="@+id/ed_address_act_order"
                    android:textColor="@color/text_color_353535"
                    android:inputType="text"
                    android:imeOptions="actionNext" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp">

                <EditText
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Комментарии"
                    android:id="@+id/ed_comment_act_order"
                    android:textColor="@color/text_color_353535"
                    android:inputType="textMultiLine" />

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

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/tv_summ_act_order"
                android:textColor="@color/text_color_353535"
                android:textSize="18sp"
                android:text=" Общая сумма: "
                android:layout_marginTop="4dp" />

        </LinearLayout>
    </ScrollView>


</FrameLayout>
<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom">

    <ProgressBar
        style="?android:attr/progressBarStyle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/progressBar_act_order"
        android:visibility="gone" />

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/height_border_line_item"
        android:background="@color/color_border_item" />

    <Button
        android:text="Оформить"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/btn_send_order_act_order"
        android:background="@drawable/bg_selector_order"
        android:textColor="@drawable/btn_order_text_color" />
</LinearLayout>

Манифест сделал таким:

<activity android:name=".activities.OrderScreenActivity"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateHidden|adjustPan"/>

Это немного странно, так как adjustPan ведёт себя по другому, нежели с LinearLayout, если это слой FrameLayout

Ваш ответ

Нажимая на кнопку «Отправить ответ», вы соглашаетесь с нашими условиями использования и подтверждаете, что прочитали и поняли наши политику конфиденциальности и нормы поведения.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.