android - 按钮隐藏在带有折叠工具栏的嵌套 ScrollView 中

标签 android button android-scrollview android-nestedscrollview

我在注册 fragment 中使用带有嵌套 ScrollView 的折叠工具栏,但是当我点击一些编辑文本并在滚动时打开键盘时,底部的注册按钮第一次没有完全显示到底部然后按钮完全可见。

图片附在下面。

打开键盘之前
enter image description here

当键盘打开时
enter image description here

键盘关闭后
enter image description here

这是xml代码。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="10dp"
        android:orientation="vertical">

            <android.support.design.widget.TextInputLayout
                style="@style/StyledTilEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/stemiIcon"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <EditText
                    android:id="@+id/et_reg_name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Name"
                    android:imeOptions="actionNext"
                    android:inputType="textPersonName" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                style="@style/StyledTilEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/stemiIcon"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <EditText
                    android:id="@+id/et_reg_phone"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Phone"
                    android:imeOptions="actionNext"
                    android:inputType="phone" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                style="@style/StyledTilEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/stemiIcon"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <EditText
                    android:id="@+id/et_reg_dob"
                    style="@style/StyledTilEditText"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:clickable="true"
                    android:cursorVisible="false"
                    android:editable="false"
                    android:hint="Date of birth"
                    android:imeOptions="actionNext"
                    android:inputType="none"
                    android:longClickable="false" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                style="@style/StyledTilEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/stemiIcon"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <EditText
                    android:id="@+id/et_reg_email"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Email"
                    android:imeOptions="actionNext"
                    android:inputType="textEmailAddress" />
            </android.support.design.widget.TextInputLayout>

            <android.support.design.widget.TextInputLayout
                style="@style/StyledTilEditText"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/stemiIcon"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

                <EditText
                    android:id="@+id/et_reg_password"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Password"
                    android:imeOptions="actionNext"
                    android:inputType="textPassword" />
            </android.support.design.widget.TextInputLayout>

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginStart="10dp"
                android:layout_marginTop="15dp"
                android:text="Gender"
                android:textColor="@color/text_line" />

            <com.agiliztech.stepout2play.customviews.AnswerTemplateView
                android:id="@+id/answerLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/have_diabetes"
                android:layout_margin="10dp"
                app:clickedColor="@color/selected_gender"
                app:colorView="@color/color_white"
                app:textBackground="@drawable/text_border_with_color"
                app:textColor="@color/selected_gender">

            </com.agiliztech.stepout2play.customviews.AnswerTemplateView>

        <Button
            android:id="@+id/bt_reg_register"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:background="@color/btn_color"
            android:text="REGISTER"
            android:textColor="@color/color_white" />
    </LinearLayout>


  </android.support.v4.widget.NestedScrollView>
</RelativeLayout>

最佳答案

设置高度为match_parent并添加android:fillViewport元素

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp"
    android:fillViewport="true"/>
    ...
    ...
</android.support.v4.widget.NestedScrollView>

关于android - 按钮隐藏在带有折叠工具栏的嵌套 ScrollView 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49233900/

相关文章:

android - 当用户按下按钮时创建一个新的弹出窗口

android - 将触摸事件从 ScrollView 委托(delegate)给垂直 ViewPager

java - float 操作按钮和 CardView

javascript - Dojo DGrid - 如何将按钮添加到列的标签中?

android - 使用视差滚动制作安卓动态壁纸

Android - 从 jar 中调用 Activity

android - 如何构建用户输入 android 应用程序?

android - 如何在 Fragments 中添加一个按钮

android - 如何垂直滚动 ConstraintLayout?

android - Andengine LANDSCAPE_SENSOR