0

我有一个活动,其中包含一个由包含标签(在活动顶部)添加的片段和一个主要的中央片段。主片段还包含 editText 小部件。当我单击 edittext 键盘时,它会根据所选的窗口显示出来,SoftInputMode 键盘会向上移动窗口(上部片段消失在屏幕后面)或与主片段上键盘下方的按钮重叠。(两种情况下都不会出现滚动)。

我需要可滚动的片段窗口,但它不可能吗?如何?

文件:

活动:

<?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" />

主要片段:

<?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>

4

1 回答 1

0

您可以将以下代码用于您的活动清单文件,我认为它应该可以解决您的问题

android:windowSoftInputMode="adjustPan|adjustResize"
于 2019-10-04T05:32:54.277 回答