0

I have an activity that contains one fragment added by the include tag (at the top of the activity) and one main central fragment. The main fragment also contains the editText widget. When I click on the edittext keyboard it is displayed and based on the window chosen, the SoftInputMode keyboard moves the window upwards (the upper fragment disappears behind the screen) or overlaps the buttons below the keyboard on the main fragment. (scrolling does not appear in both cases).

I need scrollable fragment window, but its impossible? How?

Xmls:

Activity:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/bg_second"
android:keepScreenOn="true">

<FrameLayout
    android:id="@+id/fl_work_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="bottom|right|end"
    tools:ignore="RtlHardcoded" />

<include layout="@layout/view_menu_main" />

Main fragment:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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="match_parent">

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        app:layout_constraintBottom_toTopOf="@id/tv_tariff_label"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/textInputLayout">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_border"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/space_large_m"
            android:background="?attr/bg_main"
            android:minHeight="120dp"
            android:paddingStart="@dimen/space_medium_xl"
            android:paddingTop="@dimen/space_medium_l"
            android:paddingEnd="@dimen/space_medium_xl" />

        <TextView
            android:id="@+id/tv_empty_point"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="@dimen/space_medium_s"
            android:text="@string/road_to_empty_text"
            android:textAlignment="center"
            android:textColor="?attr/text_main"
            tools:textColor="@color/black" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="@dimen/space_medium_xl"
            android:tint="@android:color/white"
            app:backgroundTint="@color/bg_button_light"
            app:layout_anchor="@id/rv_border"
            app:layout_anchorGravity="bottom|right|end"
            app:srcCompat="@android:drawable/ic_input_add" />
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/textInputLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="70dp"
        android:paddingStart="@dimen/space_small_l"
        android:paddingEnd="@dimen/space_small_l"
        android:theme="@style/TextInputLayout"
        app:layout_constraintBottom_toTopOf="@id/tv_tariff_label"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="+7949919">

        <EditText
            android:id="@+id/phone_number"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/phone_number_of_client"
            android:importantForAutofill="no"
            android:inputType="phone"
            android:maxLength="15"
            android:maxLines="1"
            android:singleLine="true"
            android:textColor="?attr/text_main"
            android:textColorHighlight="@android:color/darker_gray"
            android:textColorHint="@android:color/darker_gray"
            tools:textColor="@color/black" />
    </com.google.android.material.textfield.TextInputLayout>

    <TextView
        android:id="@+id/tv_tariff_label"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp"
        android:padding="@dimen/space_medium_s"
        android:singleLine="true"
        android:text="@string/work_main_tariff"
        android:textColor="?attr/text_main"
        android:textSize="@dimen/font_size_huge"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/textInputLayout"
        tools:textColor="@color/black" />

    <LinearLayout
        android:id="@+id/ll_tariff_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/bg_second"
        android:orientation="horizontal"
        android:weightSum="3"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/tv_tariff_label">

        <TextView
            android:id="@+id/tv_tariff"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1.8"
            android:clickable="true"
            android:focusable="true"
            android:gravity="center_vertical"
            android:paddingStart="@dimen/space_medium_s"
            android:paddingEnd="@dimen/space_medium_s"
            android:tag="tariff"
            android:textColor="?attr/text_main"
            android:textSize="@dimen/font_size_huge"
            tools:text="My tariff"
            tools:textColor="@color/black" />

        <Button
            android:id="@+id/add_opt_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|end"
            android:layout_marginEnd="4dp"
            android:layout_weight="1"
            android:background="@drawable/custom_button_green"
            android:text="@string/options_title"
            android:textColor="?attr/text_button"
            android:textSize="@dimen/font_size_large"
            android:visibility="invisible"
            tools:textColor="@color/white" />

        <ProgressBar
            android:id="@+id/p_bar_options"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|end"
            android:layout_marginEnd="4dp"
            android:layout_weight="1.2"
            android:padding="4dp"
            android:text="@string/options_title"
            android:textColor="?attr/text_button"
            android:textSize="@dimen/font_size_large"
            android:theme="@style/accentStyle"
            android:visibility="gone"
            tools:textColor="@color/white" />
    </LinearLayout>

    <Button
        android:id="@+id/btn_start_work"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/button_height"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="50dp"
        android:background="@drawable/custom_button_green"
        android:text="@string/work_btn_begin"
        android:textColor="?attr/text_button"
        android:textSize="@dimen/font_size_large"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/ll_tariff_view"
        tools:textColor="@color/white" />

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:theme="@style/accentStyle"
        android:visibility="gone"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/ll_tariff_view"
        tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

G. Ciardini
  • 1,210
  • 1
  • 17
  • 32
AlexS
  • 918
  • 1
  • 12
  • 28

1 Answers1

0

You can use below code into Manifest file for your activity, I think it should resolve your problem

android:windowSoftInputMode="adjustPan|adjustResize"
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92