在软键盘显示后,是否可以让我的视图滚动到底部?

时间:2019-08-03 14:01:13

标签: android android-view android-softkeyboard android-scrollview android-nestedscrollview

我在Android中有一个nestedScrollView,它没有滚动到窗体的底部。我必须单击“下一步”,我知道我不喜欢这样做,所以我的用户也不会。

我已经重新提出了这个主题,唯一出现的是“ Android: ScrollView not scrolling with keyboard out”。我尝试了该解决方案,但不适用于我。他们给的任何解决方案我都尝试过。

        <activity
                android:name=".activities.PersonalInfomation"
                android:configChanges="orientation"
                android:label="@string/title_activity_personal_infomation"
                android:windowSoftInputMode="adjustResize"
                android:screenOrientation="portrait"
                android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:background="@color/colorWhite"
        tools:context=".activities.PersonalInfomation"
>

    <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="60dp" app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
            android:background="@color/colorPrimaryDark" android:id="@+id/constraintLayout2">

        <Button
                android:layout_width="35dp"
                android:layout_height="30dp"
                android:id="@+id/button_yes" app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="16dp"
                android:layout_marginStart="16dp" android:textStyle="bold" android:textColor="@color/calendar_bg"
                android:background="@drawable/backward_arrow" android:layout_marginTop="8dp"
                android:layout_marginBottom="8dp"
                android:onClick="closeRegistration"/>
        <TextView
                android:text="@string/registration"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/textView8"
                app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
                android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintBottom_toBottomOf="parent"
                android:textAppearance="@style/TextAppearance.AppCompat.Display1" android:textSize="24sp"
                android:textColor="@color/calendar_selected_range_bg"/>
    </android.support.constraint.ConstraintLayout>
    <android.support.v4.widget.NestedScrollView

            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:background="@color/colorWhite"

            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:id="@+id/nestedScrollView"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintTop_toBottomOf="@+id/constraintLayout2" android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp">

        <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content">
            <android.support.constraint.ConstraintLayout android:layout_width="match_parent"
                                                         android:layout_height="wrap_content"
                                                         android:id="@+id/all_info">

                <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" android:id="@+id/personal_info_wrapper"
                        android:background="@color/deepGray"
                        android:padding="10dp"
                        app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"

                        app:layout_constraintEnd_toEndOf="parent"
                >
                    <TextView android:layout_width="match_parent"
                              android:id="@+id/attention"
                              android:textColor="@color/darkBlue"
                              android:text="@string/attention_information_requiements"
                              android:layout_height="wrap_content"/>
                    <TextView android:layout_width="match_parent"
                              android:id="@+id/personal_info_string"
                              android:text="@string/personal_information"
                              android:textColor="@color/darkBlue"
                              android:layout_height="wrap_content"/>
                </LinearLayout>
                <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_margin="@dimen/text_margin"
                        android:text="@string/points_12_text"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintEnd_toEndOf="parent" android:layout_marginLeft="8dp"
                        android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:layout_marginRight="8dp"
                        android:id="@+id/long_text" android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/personal_info_wrapper"
                        android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textColor="@color/black"
                        android:textSize="16sp"/>

                <Spinner android:layout_width="match_parent"
                         android:id="@+id/title_client"
                         android:layout_height="wrap_content"
                         app:layout_constraintTop_toBottomOf="@+id/long_text"
                         app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
                         android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
                         android:layout_marginTop="8dp" android:layout_marginBottom="7dp"
                         app:layout_constraintBottom_toTopOf="@+id/firstname"></Spinner>


                <EditText android:layout_width="match_parent"
                          android:id="@+id/firstname"
                          android:hint="@string/name"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="8dp"
                          app:layout_constraintTop_toBottomOf="@+id/title_client"
                          app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
                          android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                          android:layout_marginEnd="8dp"
                          android:layout_marginRight="8dp" android:textColor="@color/string_gray"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line2"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/firstname"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>

                <EditText android:layout_width="match_parent"
                          android:id="@+id/middlename"
                          android:hint="@string/middle_name_optional"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="8dp"
                          app:layout_constraintTop_toBottomOf="@+id/firstname"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintEnd_toEndOf="parent" android:layout_marginLeft="8dp"
                          android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
                          android:layout_marginRight="8dp"
                          android:textColor="@color/string_gray"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line1"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/middlename"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>

                <EditText android:layout_width="match_parent"
                          android:id="@+id/lastname"
                          android:hint="@string/last_name"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="8dp"
                          app:layout_constraintTop_toBottomOf="@+id/middlename"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintEnd_toEndOf="parent" android:layout_marginLeft="8dp"
                          android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
                          android:layout_marginRight="8dp"
                          android:textColor="@color/string_gray"/>
                <View android:layout_width="0dp"
                      android:id="@+id/line3"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/lastname"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>


                <EditText android:layout_width="match_parent"
                          android:id="@+id/suffix"
                          android:hint="@string/suffix_optional"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="8dp"
                          app:layout_constraintTop_toBottomOf="@+id/lastname"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintEnd_toEndOf="parent" android:layout_marginLeft="8dp"
                          android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
                          android:layout_marginRight="8dp"
                          android:textColor="@color/string_gray"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line4"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/suffix"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>

                <EditText android:layout_width="match_parent"
                          android:id="@+id/dob"
                          android:hint="@string/date_of_birth"
                          android:layout_height="wrap_content"
                          android:layout_marginTop="8dp"
                          app:layout_constraintTop_toBottomOf="@+id/suffix"
                          app:layout_constraintStart_toStartOf="parent"
                          app:layout_constraintEnd_toEndOf="parent" android:layout_marginLeft="8dp"
                          android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
                          android:layout_marginRight="8dp"
                          android:textColor="@color/string_gray"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line5"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/dob"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>

                <Spinner android:layout_width="match_parent" android:layout_height="match_parent"
                         android:layout_marginTop="8dp"
                         android:id="@+id/gender"
                         app:layout_constraintTop_toBottomOf="@+id/dob" app:layout_constraintStart_toStartOf="parent"
                         app:layout_constraintEnd_toEndOf="parent" android:layout_marginLeft="8dp"
                         android:layout_marginStart="8dp" android:layout_marginEnd="8dp"
                         android:layout_marginRight="8dp"></Spinner>

                <View android:layout_width="0dp"
                      android:id="@+id/line6"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/gender"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:padding="10dp"
                        android:background="@color/deepGray"
                        android:layout_marginTop="8dp" app:layout_constraintTop_toBottomOf="@+id/gender"
                        app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"
                        android:id="@+id/oneway_layout">
                    <TextView android:layout_width="match_parent"
                              android:id="@+id/information"
                              android:textColor="@color/darkBlue"
                              android:text="@string/contact_information"
                              android:layout_height="match_parent" android:textStyle="bold"/>
                </LinearLayout>
                <EditText
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:inputType="textPostalAddress"
                        android:ems="10"
                        android:id="@+id/street_address" android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/oneway_layout"
                        app:layout_constraintStart_toStartOf="parent"
                        android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                        app:layout_constraintEnd_toEndOf="parent"
                        android:textColor="@color/string_gray" android:hint="@string/address"/>
                <View android:layout_width="0dp"
                      android:id="@+id/line7"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/street_address"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <EditText
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:inputType="textPostalAddress"
                        android:ems="10"
                        android:id="@+id/street_address_2" android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/street_address"
                        app:layout_constraintStart_toStartOf="parent"
                        android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                        app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
                        android:layout_marginRight="8dp" android:textColor="@color/string_gray"
                        android:hint="@string/street_address_2"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line8"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/street_address_2"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>

                <EditText
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:inputType="textPostalAddress"
                        android:ems="10"
                        android:id="@+id/city_town" android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/street_address_2"
                        app:layout_constraintStart_toStartOf="parent"
                        android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                        app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
                        android:layout_marginRight="8dp" android:textColor="@color/string_gray"
                        android:hint="@string/city"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line9"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/city_town"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <EditText
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:ems="10"
                        android:id="@+id/state_province" android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/city_town"
                        app:layout_constraintStart_toStartOf="parent"
                        android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                        app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
                        android:layout_marginRight="8dp" android:inputType="textAutoCorrect|textPersonName"
                        android:textColor="@color/string_gray" android:hint="@string/state"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line10"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/state_province"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <EditText
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:inputType="number"
                        android:ems="10"
                        android:id="@+id/zip_code" android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/state_province"
                        app:layout_constraintStart_toStartOf="parent"
                        android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                        app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
                        android:layout_marginRight="8dp" android:textColor="@color/string_gray"
                        android:hint="@string/zip_code"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line11"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/zip_code"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <Spinner
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" android:id="@+id/spinner_country_region"
                        android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/zip_code"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintEnd_toEndOf="parent" android:layout_marginLeft="8dp"
                        android:layout_marginStart="8dp" android:layout_marginEnd="8dp" android:layout_marginRight="8dp"
                        style="@style/spinner_style"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line12"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/spinner_country_region"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <EditText
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:inputType="phone"
                        android:ems="10"
                        android:id="@+id/mobile_number" android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/spinner_country_region"
                        app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
                        android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
                        android:layout_marginEnd="8dp" android:layout_marginRight="8dp"
                        android:textColor="@color/string_gray"
                        android:hint="@string/phone"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line13"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/mobile_number"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <Spinner
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content" android:id="@+id/spinner2"
                        android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/mobile_number"
                        app:layout_constraintStart_toStartOf="parent"
                        android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                        app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
                        android:layout_marginRight="8dp"/>

                <View android:layout_width="0dp"
                      android:id="@+id/line14"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/spinner2"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <EditText
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:inputType="textEmailAddress"
                        android:ems="10"
                        android:id="@+id/email_contact_login" android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/spinner2"
                        app:layout_constraintStart_toStartOf="parent"
                        android:layout_marginLeft="8dp" android:layout_marginStart="8dp"
                        app:layout_constraintEnd_toEndOf="parent" android:layout_marginEnd="8dp"
                        android:layout_marginRight="8dp" android:textColor="@color/string_gray"
                        android:hint="@string/email"/>
                <View android:layout_width="0dp"
                      android:id="@+id/line15"
                      android:layout_height="2dp"
                      android:background="@color/border_blue"
                      app:layout_constraintBottom_toBottomOf="@+id/email_contact_login"
                      app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"/>
                <Button
                        android:text="@string/continue1"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content" android:id="@+id/button_continue"
                        android:layout_marginTop="8dp"
                        app:layout_constraintTop_toBottomOf="@+id/line15"
                        app:layout_constraintStart_toStartOf="parent" android:layout_marginLeft="8dp"
                        android:layout_marginStart="8dp" app:layout_constraintEnd_toEndOf="parent"
                        android:onClick="createAccount"
                        android:layout_margin="10dp"
                        android:layout_marginEnd="8dp" android:layout_marginRight="8dp"
                        android:textColor="@color/colorWhite"
                        android:background="@drawable/buttonpay" android:layout_marginBottom="16dp"
                        app:layout_constraintBottom_toBottomOf="parent"/>


            </android.support.constraint.ConstraintLayout>
            <android.support.constraint.ConstraintLayout
                    android:layout_below="@+id/all_info"
                    android:layout_margin="10dp"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

            </android.support.constraint.ConstraintLayout>
        </RelativeLayout>

    enter code here

    </android.support.v4.widget.NestedScrollView>
</android.support.constraint.ConstraintLayout>

我只希望能够滚动到显示按钮以继续。

0 个答案:

没有答案