3

I am using collapsing toolbar with nested ScrollView in Registration fragment, But the register button at the bottom is not fully displaying for the first time when I click on some edit text and opens keyboard if I scroll to bottom then the button is fully visible.

The image is attached below.

Before opening keyboard
enter image description here

when keyboard opens
enter image description here

After keyboard closed
enter image description here

Here is the xml code.

<?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>
Poojashree
  • 61
  • 4

3 Answers3

1

Set height to match_parent and add android:fillViewport element

<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>
Lucifer
  • 29,392
  • 25
  • 90
  • 143
  • Did you try cleaning the project ? because this solution should work. – Lucifer Mar 12 '18 at 11:28
  • Thanks! That helped me to fill the empy space at the bottom of the recycler view when using collapsing toolbar layout. – Erkan May 16 '20 at 09:08
0

Add

android:windowSoftInputTypeMode="adjustResize|stateAlwaysHidden"    to activity in your manifest, then make your nestedtscrollview height match parent and fillviewport true in the xml
Nibin Salim
  • 71
  • 1
  • 7
0

Try to add android:minHeight to yourCollapsingToolbarLayout