Fragment中的ScrollView在软键盘出现时不滚动

Tar*_*tar 4 android android-softkeyboard android-fragments android-scrollview android-scroll

我有一个Fragment,有一个ScrollViewFragment

<ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:paddingBottom="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/appbar">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.tatar.mobile.widget.CardSelectionView
            android:id="@+id/card_selection_view"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            app:accountRightTextView1="@string/available"
            app:accountTitleTextView="@string/from"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/line_text_view"
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginTop="8dp"
            android:background="@color/gray.light"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/card_selection_view" />

        <Spinner
            android:id="@+id/type_spinner"
            style="@style/spinner"
            android:layout_marginTop="8dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/line_text_view" />

        <Spinner
            android:id="@+id/company_spinner"
            style="@style/spinner"
            android:layout_marginTop="8dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/type_spinner" />

        <LinearLayout
            android:id="@+id/dynamic_form_container"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/company_spinner" />

        <Spinner
            android:id="@+id/installment_spinner"
            style="@style/spinner"
            android:layout_marginTop="8dp"
            android:visibility="invisible"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/dynamic_form_container" />

        <Button
            android:id="@+id/continue_button"
            style="@style/action_button"
            android:layout_marginTop="16dp"
            android:text="@string/continue_button_text"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/installment_spinner" />

    </android.support.constraint.ConstraintLayout>

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

LinearLayout用的IDdynamic_form_containerScrollView包含将通过Web服务调用填充,可能有多达6-7输入字段根据发送到Web服务的参数表单输入字段。所以,表格的高度有点高,这就是问题的开始。当我尝试在输入字段中输入内容时,软键盘会出现,而其他一些输入字段则保留在软键盘下方,无法滚动。

我试图把这个表现出来ActivityFragment但它没有帮助。

android:windowSoftInputMode="adjustResize|stateHidden"
Run Code Online (Sandbox Code Playgroud)

我希望能够在软键盘出现时滚动。我该如何解决这个问题?

任何帮助,将不胜感激

Tar*_*tar 5

getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Run Code Online (Sandbox Code Playgroud)

onCreateView方法中为我工作。


Ume*_*HIR -1

您好,请参考下面的代码

这对我来说是工作..

<RelativeLayout 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"
android:background="@color/white">

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">


    </android.support.constraint.ConstraintLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml

  <activity
        android:name=".ui.activities.Activity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar" />
Run Code Online (Sandbox Code Playgroud)